all repos — Legends-RPG @ 77d11c24818c6da89b2c8cc04817e3beb8274131

A fantasy mini-RPG built with Python and Pygame.

Minor refactor, sped up timer.
Justin Armstrong justinmeister@gmail.com
Sun, 27 Apr 2014 10:43:05 -0700
commit

77d11c24818c6da89b2c8cc04817e3beb8274131

parent

d96752daa4c3f2dd549a2434ddabf1086675b823

1 files changed, 6 insertions(+), 8 deletions(-)

jump to
M data/states/battle.pydata/states/battle.py

@@ -96,7 +96,7 @@ def update(self, surface, keys, current_time):

"""Update the battle state""" self.current_time = current_time self.check_input(keys) - self.check_for_timed_events() + self.check_timed_events() self.check_if_battle_won() self.enemy_group.update(current_time) self.player.update(keys, current_time)

@@ -124,10 +124,6 @@ elif self.state == c.SELECT_ENEMY:

self.state = c.PLAYER_ATTACK self.notify(self.state) - elif self.state == c.PLAYER_ATTACK: - self.state = c.ENEMY_DEAD - self.info_box.state = c.ENEMY_DEAD - elif self.state == c.SELECT_ITEM or self.state == c.SELECT_MAGIC: if self.arrow.index == (len(self.arrow.pos_list) - 1): self.state = c.SELECT_ACTION

@@ -138,14 +134,16 @@

if keys[pg.K_RETURN] == False and keys[pg.K_SPACE] == False: self.allow_input = True - def check_for_timed_events(self): + def check_timed_events(self): """ Check if amount of time has passed for timed events. """ - timed_states = [c.DISPLAY_ENEMY_ATTACK_DAMAGE, c.ENEMY_HIT, c.ENEMY_DEAD] + timed_states = [c.DISPLAY_ENEMY_ATTACK_DAMAGE, + c.ENEMY_HIT, + c.ENEMY_DEAD] if self.state in timed_states: - if (self.current_time - self.timer) > 1500: + if (self.current_time - self.timer) > 1200: if self.state == c.DISPLAY_ENEMY_ATTACK_DAMAGE: if self.enemy_index == (len(self.enemy_list) - 1): self.state = c.SELECT_ACTION