From 0853c048441a7d6f41eba6db039fb04eb81a1058 Mon Sep 17 00:00:00 2001 From: Eren <2120548@stud.hs-mannheim.de> Date: Tue, 28 Mar 2023 16:47:24 +0200 Subject: [PATCH] =?UTF-8?q?Kommentare=20hinzugef=C3=BCgt,=20die=20auskomme?= =?UTF-8?q?ntiert=20werden=20k=C3=B6nnen,=20damit=20Hintergr=C3=BCnde=20au?= =?UTF-8?q?sgetestet=20werden=20k=C3=B6nnen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/data/levels/levels.json | 4 ++-- project/main.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/project/data/levels/levels.json b/project/data/levels/levels.json index 6d5cb57..4da65a4 100644 --- a/project/data/levels/levels.json +++ b/project/data/levels/levels.json @@ -8,7 +8,7 @@ }, { "name": "level-01", - "theme": "tutorial", + "theme": "castle", "abilities": [ ], "file": "level-01.csv" @@ -48,7 +48,7 @@ ], "file": "level-06.csv" }, - { + { "name": "level-07", "theme": "castle", "abilities": [ diff --git a/project/main.py b/project/main.py index 43ac02c..3427e0c 100644 --- a/project/main.py +++ b/project/main.py @@ -17,8 +17,15 @@ from ui_elements.KeyManager import KeyManager from ui_elements.LevelMenu import LevelMenu from ui_elements.TextLabel import TextLabel -what_to_run = 'menu' +what_to_run = 'level' +WIDTH = 12 * 71 * 1.5 +HEIGHT = 12 * 40 * 1.5 + +# Background to test for level design +# test_background_castle = pygame.transform.scale(pygame.image.load('data/sprites/castle_bg.png'), (WIDTH, HEIGHT)) +# test_background_cave = pygame.transform.scale(pygame.image.load('data/sprites/cave_bg.png'), (WIDTH, HEIGHT)) +# test_background_tutorial = pygame.transform.scale(pygame.image.load('data/sprites/tutorial_bg.png'), (WIDTH, HEIGHT)) def apply_frame_rate(number: float): """ @@ -35,6 +42,7 @@ if what_to_run == 'menu': screen_height = 12 * 40 * 1.5 screen_width = 12 * 71 * 1.5 + pygame.init() screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption("PM GAME") @@ -110,6 +118,7 @@ elif what_to_run == 'level': pygame.init() screen = pygame.display.set_mode((12 * ConstantsParser.CONFIG.level_size[0] * screen_transform.scale[0], 12 * ConstantsParser.CONFIG.level_size[1] * screen_transform.scale[1])) + pygame.display.set_caption("PM GAME") clock = pygame.time.Clock() frame_rate = 30 @@ -133,6 +142,7 @@ elif what_to_run == 'level': while True: clock.tick(frame_rate) + calculated_frame_rate_text.text = f"{round(clock.get_fps())} FPS" pygame_events: list[pygame.event.Event] = pygame.event.get() @@ -145,6 +155,8 @@ elif what_to_run == 'level': quit() screen.fill((0, 0, 0)) + # Playground to test background on any level + # screen.blit(test_background_castle, (0, 0)) sprite_manager.tick(TickData(apply_frame_rate(1), pygame_events, key_manager, click_events, screen_transform)) sprite_manager.draw(screen, screen_transform)