change name and add first version of start screen

main
Fabian Hoppe 2023-03-29 17:34:18 +02:00
parent 0ad5c47d6d
commit 695b4ad6b1
2 changed files with 7 additions and 3 deletions

View File

@ -25,8 +25,8 @@ class MainMenuScreenManager(ScreenManager):
def initialize(self): def initialize(self):
size = CoordinateTransform.transform_screen_to_world(self.main_loop.window_size, self.main_loop.screen_transform) size = CoordinateTransform.transform_screen_to_world(self.main_loop.window_size, self.main_loop.screen_transform)
self.create_button("START", size[0] * 0.5, size[1] * 0.5, 70) self.create_button("START", size[0] * 0.495, size[1] * 0.772, 38)
self.create_button("SCREEN SIZE", size[0] * 0.5, size[1] * 0.7, 40) self.create_button("SCREEN SIZE", size[0] * 0.85, size[1] * 0.9, 20)
def create_button(self, name: str, x_position, y_position, font_size): def create_button(self, name: str, x_position, y_position, font_size):
label = TextLabel(name, x_position, y_position, font_size, alignment="center") label = TextLabel(name, x_position, y_position, font_size, alignment="center")

View File

@ -22,12 +22,14 @@ BACKGROUND_IMAGES_UNSCALED = {
'tutorial': pygame.image.load('data/sprites/tutorial_bg.png'), 'tutorial': pygame.image.load('data/sprites/tutorial_bg.png'),
'castle': pygame.image.load('data/sprites/castle_bg.png'), 'castle': pygame.image.load('data/sprites/castle_bg.png'),
'cave': pygame.image.load('data/sprites/cave_bg.png'), 'cave': pygame.image.load('data/sprites/cave_bg.png'),
'menu': pygame.image.load('data/sprites/intro_bg.png'),
} }
BACKGROUND_IMAGES_SCALED = { BACKGROUND_IMAGES_SCALED = {
'tutorial': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['tutorial'], (1, 1)), 'tutorial': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['tutorial'], (1, 1)),
'castle': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['castle'], (1, 1)), 'castle': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['castle'], (1, 1)),
'cave': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['cave'], (1, 1)), 'cave': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['cave'], (1, 1)),
'menu': pygame.transform.scale(BACKGROUND_IMAGES_UNSCALED['menu'], (1, 1)),
} }
@ -53,7 +55,7 @@ class MainLoop:
self.window_size: tuple[float, float] = (1, 1) self.window_size: tuple[float, float] = (1, 1)
pygame.init() pygame.init()
pygame.display.set_caption("PM GAME") pygame.display.set_caption("Don't Get Busted")
self.update_position_scale(self.screen_transform) self.update_position_scale(self.screen_transform)
@ -176,6 +178,8 @@ class MainLoop:
self.sprite_manager.tick(tick_data) self.sprite_manager.tick(tick_data)
if self.level is not None and self.game_state == self.GAME_STATE_LEVEL: if self.level is not None and self.game_state == self.GAME_STATE_LEVEL:
self.screen.blit(BACKGROUND_IMAGES_SCALED[self.level.theme], (0, 0)) self.screen.blit(BACKGROUND_IMAGES_SCALED[self.level.theme], (0, 0))
elif self.game_state == self.GAME_STATE_MENU:
self.screen.blit(BACKGROUND_IMAGES_SCALED['menu'], (0, 0))
self.sprite_manager.draw(self.screen, self.screen_transform) self.sprite_manager.draw(self.screen, self.screen_transform)
pygame.display.update() pygame.display.update()