Files
examnow/solar_vis.py
2026-06-26 10:40:09 +03:00

46 lines
1.7 KiB
Python

import pygame
from solar_input import handle_events
class SolarApp:
def __init__(self, system, save_callback):
pygame.init()
self.system = system
self.save_callback = save_callback
self.running = True
self.min_width = 850
self.min_height = 560
self.screen = pygame.display.set_mode((system.width, system.height), pygame.RESIZABLE)
pygame.display.set_caption("Solar System - Ticket 3")
self.clock = pygame.time.Clock()
self.font = pygame.font.SysFont("arial", 20)
def resize_window(self, width, height):
self.screen = pygame.display.set_mode((width, height), pygame.RESIZABLE)
self.system.resize(width, height)
def draw_text(self, text, x, y):
image = self.font.render(text, True, (230, 230, 230))
self.screen.blit(image, (x, y))
def draw_info(self):
status = "PAUSE" if self.system.paused else "RUN"
orbits = "ON" if self.system.show_orbits else "OFF"
self.draw_text("Ticket 3", 30, 25)
self.draw_text("2 stars | 11 planets + 12 planets", 30, 50)
self.draw_text("Each orbit intersects at least one orbit", 30, 75)
self.draw_text(f"Status: {status}", 30, 105)
self.draw_text(f"Orbits: {orbits}", 30, 130)
self.draw_text("SPACE - pause | O - orbits | S - save | ESC - exit", 30, self.system.height - 35)
def run(self):
while self.running:
handle_events(self, self.system, self.save_callback)
self.system.update()
self.screen.fill((10, 10, 25))
self.system.draw(self.screen, pygame)
self.draw_info()
pygame.display.flip()
self.clock.tick(60)
pygame.quit()