commit 9bd581aad4ad9c39930b14d4b04158ac3872e9e6
parent 93d32d1bc2c00bdaebc00854de7b3d034f2e92ef
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 10 May 2021 17:50:01 -0500
added pausing
Diffstat:
5 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/src/base.py b/src/base.py
@@ -118,7 +118,7 @@ class BaseManager(manager.Manager):
if surface != None:
if self.game.control_mode == CTRL_MODES.Base_Normal:
self.tile_cursor.update(surface)
- self.base_entities.update(surface)
+ self.base_entities.update(surface, self.game.control_mode not in PAUSE_MODES)
###################################################
# Section 2 - Various Base Mode Entity Subclasses #
diff --git a/src/constants.py b/src/constants.py
@@ -112,6 +112,19 @@ SCROLLABLE_TURN_MODES = [
CTRL_MODES.Turn_Select_Attack,
CTRL_MODES.Turn_Select_Push
]
+PAUSE_MODES = [
+ CTRL_MODES.Base_Pause,
+ CTRL_MODES.Turn_Pause,
+ CTRL_MODES.Turn_Display_Stats
+]
+PLUMB_BOB_DRAW_TURN_MODES = [
+ CTRL_MODES.Turn_Normal,
+ CTRL_MODES.Turn_Select_Move,
+ CTRL_MODES.Turn_Select_Attack,
+ CTRL_MODES.Turn_Choose_Skill,
+ CTRL_MODES.Turn_Choose_Item,
+ CTRL_MODES.Turn_Select_Push
+]
# Save environment
SAVE_ENV = {
diff --git a/src/entity.py b/src/entity.py
@@ -187,7 +187,7 @@ class Entity(pygame.sprite.DirtySprite):
"""
pass
- def update(self, surface = None):
+ def update(self, surface = None, to_animate = True):
"""
Draw the Entity to the surface. Also calls act() for update
logic for specific Entity children, and animate() to animate
@@ -196,7 +196,7 @@ class Entity(pygame.sprite.DirtySprite):
self.act()
if surface != None:
self.motion_move()
- if self.animated:
+ if self.animated and to_animate:
self.animate()
surface.blit(pygame.transform.flip(self.image, self.flipped[0], self.flipped[1]), self.rect)
diff --git a/src/interface.py b/src/interface.py
@@ -65,6 +65,7 @@ class GameInterface(subsystem.GameSubsystem):
"""
React to a key being pressed.
"""
+ #print(event.key)
if event.key < len(self.key_bools):
self.key_bools[event.key] = True
@@ -81,16 +82,41 @@ class GameInterface(subsystem.GameSubsystem):
of keys on a mode-by-mode basis. Called during
update.
"""
+ # HQ REACTIONS
+ if self.game.state_mode == STATE_MODES.Base_Mode:
+
+ # Handle pausing the game
+ if self.game.control_mode == CTRL_MODES.Base_Normal:
+ if self.key_bools[32]:
+ self.game.control_mode = CTRL_MODES.Base_Pause
+ self.key_bools[32] = False
+
+ # Handle unpausing the game
+ elif self.game.control_mode == CTRL_MODES.Base_Pause:
+ if self.key_bools[32]:
+ self.game.control_mode = CTRL_MODES.Base_Normal
+ self.key_bools[32] = False
+
# BATTLE REACTIONS
- if self.game.state_mode == STATE_MODES.Battle_Mode:
+ elif self.game.state_mode == STATE_MODES.Battle_Mode:
- # Handle opening the stat display dialog with the keys
if self.game.control_mode == CTRL_MODES.Turn_Normal:
+ # Handle opening the stat display dialog with the keys
if self.key_bools[105]:
self.bus.perform_turn_manager_display_stats(self.bus.fetch("turn_manager", "active_piece"))
self.game.control_mode = CTRL_MODES.Turn_Display_Stats
self.key_bools[105] = False
self.key_bools[113] = False
+ # Handle pausing the game
+ elif self.key_bools[32]:
+ self.game.control_mode = CTRL_MODES.Turn_Pause
+ self.key_bools[32] = False
+
+ # Handle unpausing the game
+ elif self.game.control_mode == CTRL_MODES.Turn_Pause:
+ if self.key_bools[32]:
+ self.game.control_mode = CTRL_MODES.Turn_Normal
+ self.key_bools[32] = False
# Handle exiting the stat display
elif self.game.control_mode == CTRL_MODES.Turn_Display_Stats:
diff --git a/src/piece.py b/src/piece.py
@@ -269,11 +269,11 @@ class PieceManager(manager.Manager):
Update the pieces and tile cursor.
"""
if surface != None:
- self.pieces.update(surface)
- if self.game.control_mode != CTRL_MODES.Battle_Dialog:
+ self.pieces.update(surface, self.game.control_mode not in PAUSE_MODES)
+ if self.game.control_mode not in PAUSE_MODES:
self.tile_cursor.update(surface)
self.center_plumb_bob()
- if self.game.control_mode in (CTRL_MODES.Turn_Normal, CTRL_MODES.Turn_Select_Move, CTRL_MODES.Turn_Select_Attack):
+ if self.game.control_mode in PLUMB_BOB_DRAW_TURN_MODES:
self.plumb_bob.update(surface)
###############################
@@ -810,11 +810,11 @@ class Piece(entity.Entity):
self.set_animation(self.sheet.animations["stand_" + self.facing.name], True)
self.back_to_stand = False
- def update(self, surface = None):
+ def update(self, surface = None, to_animate = True):
"""
Overwrite to account for health bars.
"""
- super().update(surface)
+ super().update(surface, to_animate)
self.create_facing_arrow()
if self.health_bar != None and self.health_bar_fill != None:
self.health_bar_rect.center = (self.rect.center[0], self.rect.center[1] + (TILE_HEIGHT // 5))