Return to repo list

tzed

Simple story-driven open world 2D CRPG.
Return to HMagellan.com

commit 3a1be1b5124c0a3cbd131ff38ae3b8ff7d3aee78
parent ba95489ce4eef6483c5f387bead479ba91dfb00b
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sat, 11 Sep 2021 21:19:02 -0500

added party in dungeons

Diffstat:
Mdata/etc/sheets.json | 1+
Adata/images/party1.png | 0
Msrc/game.py | 17+++++++++++++++--
Msrc/gamelib.py | 1+
Msrc/interface.py | 4++++
5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/data/etc/sheets.json b/data/etc/sheets.json @@ -12,6 +12,7 @@ "ovrly32" : [32, 32, false], "ovrly64" : [64, 64, false], "ui_tray" : [1024, 768, false], + "party1" : [192, 256, false], "dungeon1_fc" : [682, 165, false], "dungeon1_w" : [220, 512, false], "dungeon1_h" : [242, 182, false] diff --git a/data/images/party1.png b/data/images/party1.png Binary files differ. diff --git a/src/game.py b/src/game.py @@ -45,6 +45,7 @@ class Game(object): self.player = None self.player_name = "" self.party = [] + self.party_group = pygame.sprite.Group() # UI elements self.ui_font = pygame.font.Font(os.path.join(FONT_PATH, MESSAGE_FONT), MESSAGE_FONT_SIZE) # TODO: Should there be a UI font option??? @@ -178,6 +179,7 @@ class Game(object): self.current_dungeon = self.loaded_dungeons[dungeonname] self.current_dungeon.enter_dungeon(direction, floor, cell) self.collect_game_data() + self.generate_party_graphics() self.message_board.post("$PLAYERNAME enters $CURRENTDUNGEONNAME.", self.gamedata) else: return 1 @@ -218,6 +220,15 @@ class Game(object): # TODO: Mode-specific switch logic + def generate_party_graphics(self): + """ + Generate fresh versions of the party graphics for + display in battles and dungeons. + """ + for p in self.party: + pg = dungeon.DungeonSprite(self.sheets[self.party[p]["party_sheet"]].sprites[tuple(self.party[p]["party_sprite"])], (self.viewport_rect.left + (256 * self.party[p]["position"]), self.viewport_rect.center[1] + (48 * self.party[p]["row"]))) + self.party_group.add(pg) + def move_player_on_board(self, offset): """ Move the player from tile-to-tile relative to the @@ -498,8 +509,10 @@ class Game(object): self.current_board.update_board(self.screen, self.viewport_rect) if self.player != None: self.player.update(self.screen, self.viewport_rect) - elif self.state_mode == STATE_MODES.Dungeon_Mode: - self.current_dungeon.update_dungeon(self.screen) + elif self.state_mode in PARTY_MODES: + if self.state_mode == STATE_MODES.Dungeon_Mode: + self.current_dungeon.update_dungeon(self.screen) + self.party_group.update(self.screen) self.ui_group.update(self.screen) self.message_board.update_message_board(self.screen) self.update_dynamic_ui(self.screen) diff --git a/src/gamelib.py b/src/gamelib.py @@ -58,6 +58,7 @@ STATE_MODES = enum.Enum("STATE_MODES", "Main_Menu_Mode Location_Mode Overworld_M # Mode collections OVERHEAD_MODES = [STATE_MODES.Location_Mode, STATE_MODES.Overworld_Mode] +PARTY_MODES = [STATE_MODES.Dungeon_Mode, STATE_MODES.Battle_Mode] # Other enums BOARD_TYPES = enum.Enum("BOARD_TYPES", "Location Overworld") diff --git a/src/interface.py b/src/interface.py @@ -84,6 +84,7 @@ class Interface(object): if self.game.current_dungeon != None: self.game.current_dungeon.move_forward() self.game.pass_time() + self.game.generate_party_graphics() for j in CONTROLS["up"]: self.key_bools[j] = False return @@ -94,6 +95,7 @@ class Interface(object): if self.game.current_dungeon != None: self.game.current_dungeon.move_forward(True) self.game.pass_time() + self.game.generate_party_graphics() for j in CONTROLS["down"]: self.key_bools[j] = False return @@ -104,6 +106,7 @@ class Interface(object): if self.game.current_dungeon != None: self.game.current_dungeon.rotate_direction(-1) self.game.pass_time() + self.game.generate_party_graphics() for j in CONTROLS["left"]: self.key_bools[j] = False return @@ -114,6 +117,7 @@ class Interface(object): if self.game.current_dungeon != None: self.game.current_dungeon.rotate_direction() self.game.pass_time() + self.game.generate_party_graphics() for j in CONTROLS["right"]: self.key_bools[j] = False return