Return to repo list

heart-of-gold

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

commit cd693066a707280a314cc94301be56247708a6c3
parent 2ab5773795bbe873df0859ae78394d8c48789956
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 29 Dec 2020 15:53:20 -0600

battle intro logic

Diffstat:
Adata/img/battle_intro_decal_1.png | 0
Mdata/json/scenes/testdia.json | 2+-
Mdata/json/sheets.json | 7+++++++
Msrc/constants.py | 2+-
Msrc/turn.py | 22++++++++++++++++++++--
5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/data/img/battle_intro_decal_1.png b/data/img/battle_intro_decal_1.png Binary files differ. diff --git a/data/json/scenes/testdia.json b/data/json/scenes/testdia.json @@ -29,7 +29,7 @@ "effects" : [ { "call" : "ef_game_switch_control", - "data" : "Turn_Normal" + "data" : "Battle_Intro" } ] } diff --git a/data/json/sheets.json b/data/json/sheets.json @@ -223,6 +223,13 @@ "anim_class" : null, "alpha" : false }, + "battle_intro_decal_1" : { + "filename" : "battle_intro_decal_1.png", + "dimensions" : [1920, 100], + "total_sprites" : 2, + "anim_class" : null, + "alpha" : false + }, "team_indicator_small_1" : { "filename" : "team_indicator_small_1.png", "dimensions" : [12, 12], diff --git a/src/constants.py b/src/constants.py @@ -89,7 +89,7 @@ OTHER_STATS = ["HP", "EXP", "LVL", "RNK"] # Enums STATE_MODES = enum.Enum('STATE_MODES', 'Main_Menu_Mode Battle_Mode Still_Scene_Mode') -CTRL_MODES = enum.Enum('CTRL_MODES', 'No_Control Main_Menu_Normal Turn_Normal Turn_Select_Move Turn_Select_Attack Turn_Watch_Move Turn_Watch_Attack Turn_Display_Stats Turn_Watch_Guard Battle_Dialog Still_Scene_Normal') +CTRL_MODES = enum.Enum('CTRL_MODES', 'No_Control Main_Menu_Normal Turn_Normal Turn_Select_Move Turn_Select_Attack Turn_Watch_Move Turn_Watch_Attack Turn_Display_Stats Turn_Watch_Guard Battle_Dialog Battle_Intro Still_Scene_Normal') FACE_DIR = enum.Enum('FACE_DIR', 'U D L R') GAME_EFFECTS = enum.Enum('GAME_EFFECTS', 'ef_game_quit ef_game_switch_mode ef_game_switch_control') ATTACK_NOTATIONS = enum.Enum('ATTACK_NOTATIONS', 'backattack critical counter opposite weakness resist riposte ignoredef parry block sweep miss onetwo stun') diff --git a/src/turn.py b/src/turn.py @@ -34,6 +34,7 @@ class TurnManager(manager.Manager): self.in_play_pieces = [] self.turn_depth = 10 self.board_events = {} + self.intro_timer = 0 # Turn tray and other associated entities self.turn_tray = None @@ -48,7 +49,8 @@ class TurnManager(manager.Manager): """ Load up the turns for the first time. This also sets up persistent parts of the turn UI - such as the trays and action buttons. + such as the trays and action buttons. This + also sets up the battle intro timer. """ # TODO: Doing this here is not my favorite, at all... with open(os.path.join(BOARD_PATH, boardname, "events.json")) as b: self.board_events = json.load(b) @@ -68,9 +70,10 @@ class TurnManager(manager.Manager): nab = ActionButton(sheets["action_buttons_1"], (0, b), None, False, self) nab.set_position(((SCREEN_WIDTH // 8), (SCREEN_HEIGHT // 10) + (((SCREEN_HEIGHT // 14) - 4)) * b)) self.action_buttons.append(nab) + self.shift_turns() + self.intro_timer = 300 if self.board_events["start_dialog"] != None: self.play_battle_dialog(self.board_events["start_dialog"]) - self.shift_turns() def shift_turns(self): """ @@ -192,6 +195,19 @@ class TurnManager(manager.Manager): else: self.stat_screen = None + def play_battle_intro(self): + """ + Play a brief battle intro transition. This happens + immediately following any at-start battle dialogs, + and immediately after loading the board if no dialogs + are present. This method is meant to be called each + frame during a transitional mode. + """ + if self.intro_timer > 0: + self.intro_timer -= 1 + else: + self.game.control_mode = CTRL_MODES.Turn_Normal + def trigger_button_at_pos(self, pos, double_clicking = False): """ Trigger a button at the given pos, if any. The @@ -294,6 +310,8 @@ class TurnManager(manager.Manager): self.action_buttons[k].toggle_activation() elif self.game.control_mode == CTRL_MODES.Turn_Display_Stats: self.stat_screen.update(surface) + elif self.game.control_mode == CTRL_MODES.Battle_Intro: + self.play_battle_intro() ############################# # Section 2 - Turn Entities #