import pygame import os import thermostat.surfaces as surfaces # Global variables SCREEN_SIZE = (720, 720) FPS = 15 VALID_SURFACES = [ 'button_pad', 'screensaver' ] def main(is_windowed=False): """ Main scene manager to display the scenes of the application :param is_windowed: boolean to start the game in windowed mode """ pygame.init() clock = pygame.time.Clock() if is_windowed: window = pygame.display.set_mode(SCREEN_SIZE) else: window = pygame.display.set_mode(SCREEN_SIZE, pygame.FULLSCREEN) # Starts the program with the surface 'dial' as the default surface = getattr(globals()['surfaces'], 'button_pad').Surface(SCREEN_SIZE) running = True while running: clock.tick(FPS) surface.update() window.blit(surface, surface.get_rect()) if not surface.running: if surface.quit: break # Switch the surface to a new surface next_surface = surface.next_surface if next_surface not in VALID_SURFACES: raise Exception('Given surface is not a valid surface!') surface = getattr(globals()['surfaces'], next_surface).Surface(SCREEN_SIZE) pygame.display.flip() pygame.quit()