Kommentare hinzugefügt, die auskommentiert werden können, damit Hintergründe ausgetestet werden können.

main
Eren Saglam 2023-03-28 16:47:24 +02:00
parent a8d0a9627c
commit 0853c04844
2 changed files with 15 additions and 3 deletions

View File

@ -8,7 +8,7 @@
}, },
{ {
"name": "level-01", "name": "level-01",
"theme": "tutorial", "theme": "castle",
"abilities": [ "abilities": [
], ],
"file": "level-01.csv" "file": "level-01.csv"

View File

@ -17,8 +17,15 @@ from ui_elements.KeyManager import KeyManager
from ui_elements.LevelMenu import LevelMenu from ui_elements.LevelMenu import LevelMenu
from ui_elements.TextLabel import TextLabel 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): def apply_frame_rate(number: float):
""" """
@ -35,6 +42,7 @@ if what_to_run == 'menu':
screen_height = 12 * 40 * 1.5 screen_height = 12 * 40 * 1.5
screen_width = 12 * 71 * 1.5 screen_width = 12 * 71 * 1.5
pygame.init() pygame.init()
screen = pygame.display.set_mode((screen_width, screen_height)) screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("PM GAME") pygame.display.set_caption("PM GAME")
@ -110,6 +118,7 @@ elif what_to_run == 'level':
pygame.init() pygame.init()
screen = pygame.display.set_mode((12 * ConstantsParser.CONFIG.level_size[0] * screen_transform.scale[0], 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])) 12 * ConstantsParser.CONFIG.level_size[1] * screen_transform.scale[1]))
pygame.display.set_caption("PM GAME") pygame.display.set_caption("PM GAME")
clock = pygame.time.Clock() clock = pygame.time.Clock()
frame_rate = 30 frame_rate = 30
@ -133,6 +142,7 @@ elif what_to_run == 'level':
while True: while True:
clock.tick(frame_rate) clock.tick(frame_rate)
calculated_frame_rate_text.text = f"{round(clock.get_fps())} FPS" calculated_frame_rate_text.text = f"{round(clock.get_fps())} FPS"
pygame_events: list[pygame.event.Event] = pygame.event.get() pygame_events: list[pygame.event.Event] = pygame.event.get()
@ -145,6 +155,8 @@ elif what_to_run == 'level':
quit() quit()
screen.fill((0, 0, 0)) 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.tick(TickData(apply_frame_rate(1), pygame_events, key_manager, click_events, screen_transform))
sprite_manager.draw(screen, screen_transform) sprite_manager.draw(screen, screen_transform)