Merge remote-tracking branch 'origin/main'
commit
cb5db15771
|
@ -7,7 +7,7 @@
|
||||||
"file": "playground.csv"
|
"file": "playground.csv"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "0-tutorial",
|
"name": "tutorial",
|
||||||
"theme": "tutorial",
|
"theme": "tutorial",
|
||||||
"abilities": [
|
"abilities": [
|
||||||
],
|
],
|
||||||
|
|
|
@ -47,6 +47,12 @@ TILES = {
|
||||||
'i': InvisibleElement
|
'i': InvisibleElement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BACK_LAYER = [
|
||||||
|
]
|
||||||
|
FRONT_LAYER = [
|
||||||
|
'M'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class LoadedLevel:
|
class LoadedLevel:
|
||||||
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager):
|
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager):
|
||||||
|
@ -57,6 +63,26 @@ class LoadedLevel:
|
||||||
self.level_screen_manager = None
|
self.level_screen_manager = None
|
||||||
|
|
||||||
def load_level(self, level: Level):
|
def load_level(self, level: Level):
|
||||||
|
# create a wall of InvisibleElement around the level left and right
|
||||||
|
# block_left = SimpleBlockLevelElement({'name': '#', 'position': (30, 300)}, self, self.level_screen_manager)
|
||||||
|
# block_left.load(self.sprite_manager, self.spritesheet_manager, level)
|
||||||
|
# self.blocks.append(block_left)
|
||||||
|
# self.sprite_manager.add_ui_element(DrawLayers.OBJECTS_BACK, block_left)
|
||||||
|
|
||||||
|
for i in range(0, 100):
|
||||||
|
block_left = InvisibleElement({'name': 'i', 'position': (-16, i * 32)}, self, self.level_screen_manager)
|
||||||
|
block_left.load(self.sprite_manager, self.spritesheet_manager, level)
|
||||||
|
self.blocks.append(block_left)
|
||||||
|
self.sprite_manager.add_ui_element(DrawLayers.OBJECTS_BACK, block_left)
|
||||||
|
|
||||||
|
for i in range(0, 100):
|
||||||
|
block_right = InvisibleElement({'name': 'i', 'position':
|
||||||
|
(ConstantsParser.CONFIG.block_size[0] * ConstantsParser.CONFIG.level_size[0] + 4, i * 32)},
|
||||||
|
self, self.level_screen_manager)
|
||||||
|
block_right.load(self.sprite_manager, self.spritesheet_manager, level)
|
||||||
|
self.blocks.append(block_right)
|
||||||
|
self.sprite_manager.add_ui_element(DrawLayers.OBJECTS_BACK, block_right)
|
||||||
|
|
||||||
for row_number, row in enumerate(level.tiles):
|
for row_number, row in enumerate(level.tiles):
|
||||||
for tile_number, tile in enumerate(row):
|
for tile_number, tile in enumerate(row):
|
||||||
world_position = (tile_number, row_number)
|
world_position = (tile_number, row_number)
|
||||||
|
@ -71,6 +97,10 @@ class LoadedLevel:
|
||||||
|
|
||||||
if name in TILES:
|
if name in TILES:
|
||||||
element = TILES[name](tile, self, self.level_screen_manager)
|
element = TILES[name](tile, self, self.level_screen_manager)
|
||||||
|
if name in BACK_LAYER:
|
||||||
|
layer = DrawLayers.OBJECTS_BACK
|
||||||
|
elif name in FRONT_LAYER:
|
||||||
|
layer = DrawLayers.OBJECTS_FRONT
|
||||||
|
|
||||||
elif name == 'C':
|
elif name == 'C':
|
||||||
ghost_character = PlayerSprite(self.spritesheet_manager.get_sheet("ghost_character"))
|
ghost_character = PlayerSprite(self.spritesheet_manager.get_sheet("ghost_character"))
|
||||||
|
@ -81,7 +111,7 @@ class LoadedLevel:
|
||||||
|
|
||||||
elif not name == '':
|
elif not name == '':
|
||||||
print(f"Unknown tile at {position}: {name}")
|
print(f"Unknown tile at {position}: {name}")
|
||||||
element = UnknownTileLevelElement(tile, self, self.level_screen_manager)
|
element = UnknownTileLevelElement(tile, self , self.level_screen_manager)
|
||||||
|
|
||||||
if element:
|
if element:
|
||||||
self.blocks.append(element)
|
self.blocks.append(element)
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -12,11 +12,13 @@ from ui_elements.UiElement import UiElement
|
||||||
class DrawLayers:
|
class DrawLayers:
|
||||||
BACKGROUND = 'background'
|
BACKGROUND = 'background'
|
||||||
LEVEL = 'level'
|
LEVEL = 'level'
|
||||||
|
OBJECTS_BACK = 'objects_back'
|
||||||
OBJECTS = 'objects'
|
OBJECTS = 'objects'
|
||||||
|
OBJECTS_FRONT = 'objects_front'
|
||||||
PLAYER = 'player'
|
PLAYER = 'player'
|
||||||
UI = 'ui'
|
UI = 'ui'
|
||||||
|
|
||||||
DRAW_ORDER = [BACKGROUND, LEVEL, OBJECTS, PLAYER, UI]
|
DRAW_ORDER = [BACKGROUND, LEVEL, OBJECTS_BACK, OBJECTS, OBJECTS_FRONT, PLAYER, UI]
|
||||||
|
|
||||||
|
|
||||||
class SpriteManager:
|
class SpriteManager:
|
||||||
|
|
|
@ -53,7 +53,6 @@ class PlayerSprite(DynamicSprite):
|
||||||
self.is_potentially_stuck = 0
|
self.is_potentially_stuck = 0
|
||||||
|
|
||||||
if self.is_potentially_stuck == 2:
|
if self.is_potentially_stuck == 2:
|
||||||
print('stuck')
|
|
||||||
self.position_scale.position = (self.position_scale.position[0] - 5, self.position_scale.position[1])
|
self.position_scale.position = (self.position_scale.position[0] - 5, self.position_scale.position[1])
|
||||||
self.is_potentially_stuck = 0
|
self.is_potentially_stuck = 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue