Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit d4a1a38f99a9d6d80a7b813d6dcfd72bbf80ee04
parent e08614854f3dc849215ca674049c84d94cc316ec
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon, 23 Nov 2020 21:42:43 -0600

added plumb bob

Diffstat:
Mdata/img/action_buttons_1.png | 0
Adata/img/plumb_bob_1.png | 0
Mdata/json/anims.json | 10++++++++++
Mdata/json/sheets.json | 5+++++
Msrc/bus.py | 2++
Msrc/game.py | 2+-
Msrc/piece.py | 26+++++++++++++++++++++-----
Msrc/status.py | 14+++++---------
Msrc/turn.py | 1+
9 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/data/img/action_buttons_1.png b/data/img/action_buttons_1.png Binary files differ. diff --git a/data/img/plumb_bob_1.png b/data/img/plumb_bob_1.png Binary files differ. diff --git a/data/json/anims.json b/data/json/anims.json @@ -781,5 +781,15 @@ { "sprite" : [0, 7], "timer" : 1 }, { "sprite" : [0, 8], "timer" : 1 } ] + }, + "plumb_bob_1" : { + "spin" : [ + { "sprite" : [0, 0], "timer" : 8 }, + { "sprite" : [1, 0], "timer" : 8 }, + { "sprite" : [0, 1], "timer" : 8 }, + { "sprite" : [1, 1], "timer" : 8 }, + { "sprite" : [0, 2], "timer" : 8 }, + { "sprite" : [1, 2], "timer" : 8 } + ] } } diff --git a/data/json/sheets.json b/data/json/sheets.json @@ -133,5 +133,10 @@ "filename" : "affinity_icons_named_1.png", "dimensions" : [142, 100], "total_sprites" : 6 + }, + "plumb_bob_1" : { + "filename" : "plumb_bob_1.png", + "dimensions" : [22, 22], + "total_sprites" : 6 } } diff --git a/src/bus.py b/src/bus.py @@ -9,6 +9,8 @@ from .constants import * # This file contains: # 1. The ManagerBus subsystem, which handles inter-manager/inter-managed communication +# TODO: Need to raise actual errors where the bus errors happen + ##################################### # Section 1 - The ManagerBus object # ##################################### diff --git a/src/game.py b/src/game.py @@ -88,7 +88,7 @@ class Game(object): self.control_mode = CTRL_MODES.Turn_Normal self.board_manager.load_board(data) self.piece_manager.load_pieces_from_file(data) - self.piece_manager.load_tile_cursor("cursor1") + self.piece_manager.load_ui_elements() self.camera.load_camera_surface(self.board_manager.current_board.pixel_dimensions) # TODO: This maybe shouldn't happen here, probably not ideal in a more complex transition to battle self.turn_manager.initialize_turns(self.piece_manager.pieces) diff --git a/src/piece.py b/src/piece.py @@ -34,6 +34,7 @@ class PieceManager(manager.Manager): # Cursor values self.tile_cursor = None + self.plumb_bob = None def add_piece(self, piece): """ @@ -129,12 +130,15 @@ class PieceManager(manager.Manager): # Lastly, load the def as real pieces self.load_pieces_from_def(full_def) - def load_tile_cursor(self, sheet): + def load_ui_elements(self): """ - Load a TileCursor object to highlight selected tiles. + Load a TileCursor object to highlight selected tiles, + and a plumb bob to hover over the acting piece. """ - self.tile_cursor = TileCursor(self.bus.fetch("sheet_manager", "sheets")[sheet], (0, 0), - self.bus.fetch("sheet_manager", "animations")[sheet]["pulse"], True) + sh = self.bus.fetch("sheet_manager", "sheets") + an = self.bus.fetch("sheet_manager", "animations") + self.tile_cursor = TileCursor(sh["cursor1"], (0, 0), an["cursor1"]["pulse"], True) + self.plumb_bob = entity.Entity(sh["plumb_bob_1"], (0, 0), an["plumb_bob_1"]["spin"], True) def get_piece_by_name(self, name): """ @@ -213,6 +217,16 @@ class PieceManager(manager.Manager): if piece in self.pieces: self.pieces.remove(piece) + def center_plumb_bob(self): + """ + Center the plumb bob to the current + active piece. + """ + if self.plumb_bob != None: + ap = self.bus.fetch("turn_manager", "active_piece") + if ap != None: + self.plumb_bob.set_center_position((ap.rect.center[0], ap.rect.center[1] - (3 * (TILE_HEIGHT // 4)))) + def expose(self): """ Expose info about pieces to the ManagerBus. @@ -226,7 +240,6 @@ class PieceManager(manager.Manager): } self.bus.record(self.name, data) - def update_managed(self, surface = None): """ Update the pieces and tile cursor. @@ -234,6 +247,9 @@ class PieceManager(manager.Manager): if surface != None: self.pieces.update(surface) self.tile_cursor.update(surface) + self.center_plumb_bob() + if self.game.control_mode == CTRL_MODES.Turn_Normal: + self.plumb_bob.update(surface) ############################### # Section 2 - The Piece class # diff --git a/src/status.py b/src/status.py @@ -30,7 +30,7 @@ class StatusDisplay(entity.Entity): # Other important values self.manager = manager self.stat_def = stat_def # Consists of a piece's active stats and normal stats, in a dict - self.font = pygame.font.Font(os.path.join(FONT_PATH, UI_FONT), SCREEN_HEIGHT // 34) + self.font = pygame.font.Font(os.path.join(FONT_PATH, UI_FONT), SCREEN_HEIGHT // 36) self.affinity_icon = None self.name_surface = None self.name_surface_rect = None @@ -46,7 +46,7 @@ class StatusDisplay(entity.Entity): self.affinity_icon_position = (504, 84) self.name_surface_position = (94, 95) self.class_surface_position = (94, 152) - self.stat_surfaces_position = (140, 216) + self.stat_surfaces_position = (140, 218) self.equipment_surfaces_position = (510, 224) # Load up @@ -59,17 +59,13 @@ class StatusDisplay(entity.Entity): a status display. """ sh = self.manager.bus.fetch("sheet_manager", "sheets") - x = 0 - y = 0 - af = { i : j for i, j in zip(AFFINITIES, [(0, 0), (1, 0), (0, 1), (1, 1), (0, 2), (1, 2)]) } - + af = { i : j for i, j in zip(AFFINITIES, [ (y, x) for x in range(0, 3) for y in (0, 1) ]) } self.affinity_icon = entity.Entity(sh["affinity_icons_named_1"], af[self.stat_def["affinity"]], None, False) self.affinity_icon.set_position(self.affinity_icon_position) def load_text(self): """ - Load all the various text fields and - their rects. + Load all the various text fields and their rects. """ self.name_surface = self.font.render(self.stat_def["name"], False, (0, 0, 0)).convert() self.name_surface_rect = self.name_surface.get_rect() @@ -97,7 +93,7 @@ class StatusDisplay(entity.Entity): self.stat_surface_rects["SPD"].topleft = (self.stat_surfaces_position[0] + 150, self.stat_surfaces_position[1] + 45) self.stat_surfaces["LUK"] = self.font.render(str(self.stat_def["active_stats"]["LUK"]), False, (0, 0, 0)).convert() self.stat_surface_rects["LUK"] = self.stat_surfaces["LUK"].get_rect() - self.stat_surface_rects["LUK"].topleft = (self.stat_surfaces_position[0], self.stat_surfaces_position[1] + 69) + self.stat_surface_rects["LUK"].topleft = (self.stat_surfaces_position[0], self.stat_surfaces_position[1] + 68) self.stat_surfaces["MOVE"] = self.font.render(str(self.stat_def["active_stats"]["MOVE"]), False, (0, 0, 0)).convert() self.stat_surface_rects["MOVE"] = self.stat_surfaces["MOVE"].get_rect() self.stat_surface_rects["MOVE"].topleft = (self.stat_surfaces_position[0] + 18, self.stat_surfaces_position[1] + 89) diff --git a/src/turn.py b/src/turn.py @@ -50,6 +50,7 @@ class TurnManager(manager.Manager): such as the trays and action buttons. """ sheets = self.bus.fetch("sheet_manager", "sheets") + anims = self.bus.fetch("sheet_manager", "animations") self.in_play_pieces = pieces self.turn_tray = TurnTray(sheets["turn_order_tray_1"], (0, 0), None, False, sheets["turn_order_tray_extended_1"]) self.turn_tray_more_button = TurnTrayMoreButton(sheets["toggle_more_turn_button_1"], (0, 0), None, False, self)