Background image
parent
e4993f39af
commit
2bc88f34f4
|
@ -61,6 +61,7 @@ class LoadedLevel:
|
|||
name = tile['name']
|
||||
|
||||
element = None
|
||||
layer = DrawLayers.OBJECTS
|
||||
|
||||
if name in TILES:
|
||||
element = TILES[name](tile, self)
|
||||
|
@ -68,7 +69,9 @@ class LoadedLevel:
|
|||
elif name == 'C':
|
||||
ghost_character = PlayerSprite(self.spritesheet_manager.get_sheet("ghost_character"))
|
||||
ghost_character.position_scale = PositionScale((position[0], position[1]), (1, 1))
|
||||
self.sprite_manager.add_ui_element(DrawLayers.OBJECTS, ghost_character)
|
||||
layer = DrawLayers.PLAYER
|
||||
self.blocks.append(ghost_character)
|
||||
self.sprite_manager.add_ui_element(layer, ghost_character)
|
||||
|
||||
elif not name == '':
|
||||
print(f"Unknown tile at {position}: {name}")
|
||||
|
@ -76,7 +79,7 @@ class LoadedLevel:
|
|||
|
||||
if element:
|
||||
self.blocks.append(element)
|
||||
self.sprite_manager.add_ui_element(DrawLayers.OBJECTS, element)
|
||||
self.sprite_manager.add_ui_element(layer, element)
|
||||
element.load(self.sprite_manager, self.spritesheet_manager, level)
|
||||
self.elements_by_id[element.id] = element
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import pygame
|
|||
|
||||
from level.Level import Level
|
||||
from level.LevelManager import LevelManager
|
||||
from level.elements.LoadedLevel import LoadedLevel
|
||||
from level.selection.LevelScreenManager import LevelScreenManager
|
||||
from level.selection.LevelSelectionScreenManager import LevelSelectionScreenManager
|
||||
from level.selection.MainMenuScreenManager import MainMenuScreenManager
|
||||
|
@ -17,18 +16,17 @@ from sprite.SpritesheetManager import SpritesheetManager
|
|||
from ui_elements.ClickEvent import ClickEvent
|
||||
from ui_elements.KeyManager import KeyManager
|
||||
|
||||
what_to_run = 'level'
|
||||
|
||||
DEPRECATED_WIDTH = 12 * 71 * 1.5
|
||||
DEPRECATED_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'),
|
||||
(DEPRECATED_WIDTH, DEPRECATED_HEIGHT))
|
||||
|
||||
|
||||
# test_background_castle = pygame.transform.scale(pygame.image.load('data/sprites/cave_bg.png'), (DEPRECATED_WIDTH, DEPRECATED_WIDTH))
|
||||
# test_background_tutorial = pygame.transform.scale(pygame.image.load('data/sprites/tutorial_bg.png'), (DEPRECATED_WIDTH, DEPRECATED_WIDTH))
|
||||
BACKGROUND_IMAGES = {
|
||||
'tutorial': pygame.transform.scale(pygame.image.load('data/sprites/tutorial_bg.png'),
|
||||
(DEPRECATED_WIDTH, DEPRECATED_HEIGHT)),
|
||||
'castle': pygame.transform.scale(pygame.image.load('data/sprites/castle_bg.png'),
|
||||
(DEPRECATED_WIDTH, DEPRECATED_HEIGHT)),
|
||||
'cave': pygame.transform.scale(pygame.image.load('data/sprites/cave_bg.png'),
|
||||
(DEPRECATED_WIDTH, DEPRECATED_HEIGHT)),
|
||||
}
|
||||
|
||||
|
||||
def apply_frame_rate(number: float, frame_rate: float = 30):
|
||||
|
@ -145,6 +143,8 @@ class MainLoop:
|
|||
|
||||
self.screen_manager.tick(tick_data)
|
||||
self.sprite_manager.tick(tick_data)
|
||||
if self.level is not None:
|
||||
self.screen.blit(BACKGROUND_IMAGES[self.level.theme], (0, 0))
|
||||
self.sprite_manager.draw(self.screen, self.screen_transform)
|
||||
|
||||
pygame.display.update()
|
||||
|
|
Loading…
Reference in New Issue