from player import Player import pygame import sys from menu import Menu # MenĂ¼ importieren import settings from world import World from level_complete_screen import Endscreen def main(): pygame.joystick.init() joysticks = [] for i in range(pygame.joystick.get_count()): joystick = pygame.joystick.Joystick(i) joystick.init() joysticks.append(joystick) pygame.init() screen = pygame.display.set_mode((settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT)) pygame.display.set_caption("The Last Ollie - A Fred Story") clock = pygame.time.Clock() menu = Menu(screen) world = World(screen) endscreen = Endscreen(screen, 000) if settings.DEBUG else endscreen = Endscreen(screen, world.save_score) current_scene = settings.START_POINT running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if current_scene == "menu": menu.handle_event(event) if menu.ready_to_start_game: menu.ready_to_start_game = False # Reset! current_scene = "world" if current_scene == "world": result = world.handle_event(event) if result == "menu": current_scene = "menu" menu.input_active = False menu.show_main_buttons = True menu.ready_to_start_game = False if current_scene == "endscreen": action = endscreen.handle_event(event) if action == "retry": current_scene = "world" elif action == "menu": current_scene = "menu" if current_scene == "menu": menu.draw() elif current_scene == "world": if not world.player.game_paused: world.player.update(670) world.draw() else: current_scene = "endscreen" if settings.DEBUG and not hasattr(world, 'level_end_printed'): print("Level beendet!") world.level_end_printed = True elif current_scene == "endscreen": endscreen.draw() pygame.display.flip() clock.tick(60) pygame.quit() sys.exit() if __name__ == "__main__": main()