From c4410e665d71c983e43ad59f63331b1f82a78af7 Mon Sep 17 00:00:00 2001 From: Leon Grothus <leon.grothus@gmail.com> Date: Sun, 4 Feb 2024 19:11:01 +0100 Subject: [PATCH] changed main layout --- data/data.png | Bin 0 -> 92 bytes main.py | 63 ++++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 data/data.png diff --git a/data/data.png b/data/data.png new file mode 100644 index 0000000000000000000000000000000000000000..af087751117087b6c797315bb33c3d10aa53c351 GIT binary patch literal 92 zcmeAS@N?(olHy`uVBq!ia0vp^k|4|oBpBXI+Hnp@DSNs&hE&W+PT27Oz=0zN4m9`~ p{Q2Lm*fu}mM`FA4qyLO=gcuGlVe^sxD6a|9=IQF^vd$@?2>{3*9?Sp$ literal 0 HcmV?d00001 diff --git a/main.py b/main.py index 40ccb03..508a8ec 100644 --- a/main.py +++ b/main.py @@ -10,30 +10,39 @@ This is the main file of the game. It initializes PyGame and creates the screen The main event loop is also located here. """ -# Initialize PyGame -pygame.init() - -options = OptionsManager() # Load options -screen = pygame.display.set_mode(options.resolution) # Create the screen -clock = pygame.time.Clock() # Create clock - -sound_manager = SoundManager() # Create sound manager -sound_manager.set_options(options) # Set options -sound_manager.load_music() # Load music -sound_manager.play_music() # Play music - -scene_manager = SceneManager(screen, "main_menu") # Create scene manager and set default scene to main_menu - -# Main event loop -while True: - events = pygame.event.get() # Get all events - sound_manager.update(events) # Update sound manager - for event in events: - if event.type == pygame.QUIT: - pygame.quit() - sys.exit() - - scene_manager.active_scene.update(constants.DELTA_TIME, events) # Update the scene - - pygame.display.flip() # Update the display - clock.tick(constants.FRAMERATE) # Limit the framerate \ No newline at end of file +def main(): + """ + The main function of the game. It initializes PyGame and creates the screen and clock. It also creates the sound manager and scene manager. + The main event loop is also located here. + """ + + # Initialize PyGame + pygame.init() + + options = OptionsManager() # Load options + screen = pygame.display.set_mode(options.resolution) # Create the screen + clock = pygame.time.Clock() # Create clock + + sound_manager = SoundManager() # Create sound manager + sound_manager.set_options(options) # Set options + sound_manager.load_music() # Load music + sound_manager.play_music() # Play music + + scene_manager = SceneManager(screen, "main_menu") # Create scene manager and set default scene to main_menu + + # Main event loop + while True: + events = pygame.event.get() # Get all events + sound_manager.update(events) # Update sound manager + for event in events: + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + + scene_manager.active_scene.update(constants.DELTA_TIME, events) # Update the scene + + pygame.display.flip() # Update the display + clock.tick(constants.FRAMERATE) # Limit the framerate + +if __name__ == "__main__": + main() # Run the main function \ No newline at end of file -- GitLab