Return to repo list

heart-of-gold

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

commit 508f912aac5fb1fa36fad9b66fec4ae6e83305b0
parent cd3f88d1c8d13dafc20d31413a27a3410e666d61
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed, 26 Aug 2020 21:53:33 -0500

Added all animations for jisella and implemented simple animation cycler

Diffstat:
Mdata/img/jisella_1.png | 0
Msrc/game.py | 5++++-
Msrc/images.py | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Msrc/interface.py | 19+++++++++++++++++--
Msrc/vgo.py | 2+-
5 files changed, 110 insertions(+), 6 deletions(-)

diff --git a/data/img/jisella_1.png b/data/img/jisella_1.png Binary files differ. diff --git a/src/game.py b/src/game.py @@ -19,7 +19,10 @@ class Game(object): #TESTING self.testvgo = vgo.Entity(images.SHEETS["jisella_1"], (100, 100)) - self.testvgo.set_animation(images.ANIMATIONS["jisella_1"]["stand"], True, 0) + self.testvgo.set_animation(images.ANIMATIONS["jisella_1"]["stand_L"], True, 0) + self.anim_index = 0 + self.anim_index_max = len(images.ANIMATIONS["jisella_1"]) - 1 + print(self.anim_index_max) # Utility methods def toggle_on(self): diff --git a/src/images.py b/src/images.py @@ -84,7 +84,7 @@ SHEETS = { ANIMATIONS = { "jisella_1" : { - "stand" : [ + "stand_L" : [ { "sprite" : (0, 0), "timer" : 4 }, { "sprite" : (1, 0), "timer" : 4 }, { "sprite" : (2, 0), "timer" : 4 }, @@ -93,7 +93,93 @@ ANIMATIONS = { { "sprite" : (1, 1), "timer" : 4 }, { "sprite" : (2, 1), "timer" : 4 }, { "sprite" : (3, 1), "timer" : 4 } - ] + ], + "stand_R" : [ + { "sprite" : (4, 0), "timer" : 4 }, + { "sprite" : (5, 0), "timer" : 4 }, + { "sprite" : (6, 0), "timer" : 4 }, + { "sprite" : (7, 0), "timer" : 4 }, + { "sprite" : (4, 1), "timer" : 4 }, + { "sprite" : (5, 1), "timer" : 4 }, + { "sprite" : (6, 1), "timer" : 4 }, + { "sprite" : (7, 1), "timer" : 4 } + ], + "stand_B" : [ + { "sprite" : (8, 0), "timer" : 4 }, + { "sprite" : (9, 0), "timer" : 4 }, + { "sprite" : (10, 0), "timer" : 4 }, + { "sprite" : (11, 0), "timer" : 4 }, + { "sprite" : (8, 1), "timer" : 4 }, + { "sprite" : (9, 1), "timer" : 4 }, + { "sprite" : (10, 1), "timer" : 4 }, + { "sprite" : (11, 1), "timer" : 4 } + ], + "walk_L" : [ + { "sprite" : (0, 2), "timer" : 6 }, + { "sprite" : (1, 2), "timer" : 6 }, + { "sprite" : (2, 2), "timer" : 6 }, + { "sprite" : (3, 2), "timer" : 6 } + ], + "walk_R" : [ + { "sprite" : (4, 2), "timer" : 6 }, + { "sprite" : (5, 2), "timer" : 6 }, + { "sprite" : (6, 2), "timer" : 6 }, + { "sprite" : (7, 2), "timer" : 6 } + ], + "walk_B" : [ + { "sprite" : (8, 2), "timer" : 6 }, + { "sprite" : (9, 2), "timer" : 6 }, + { "sprite" : (10, 2), "timer" : 6 }, + { "sprite" : (11, 2), "timer" : 6 } + ], + "attack_L" : [ + { "sprite" : (0, 3), "timer" : 10 }, + { "sprite" : (1, 3), "timer" : 20 }, + { "sprite" : (2, 3), "timer" : 3 }, + { "sprite" : (3, 3), "timer" : 24 } + ], + "attack_R" : [ + { "sprite" : (4, 3), "timer" : 10 }, + { "sprite" : (5, 3), "timer" : 20 }, + { "sprite" : (6, 3), "timer" : 3 }, + { "sprite" : (7, 3), "timer" : 24 } + ], + "attack_B" : [ + { "sprite" : (8, 3), "timer" : 10 }, + { "sprite" : (9, 3), "timer" : 20 }, + { "sprite" : (10, 3), "timer" : 3 }, + { "sprite" : (11, 3), "timer" : 24 } + ], + "shoot_L" : [ + { "sprite" : (0, 4), "timer" : 44 }, + { "sprite" : (3, 3), "timer" : 20 } + ], + "shoot_R" : [ + { "sprite" : (4, 4), "timer" : 44 }, + { "sprite" : (7, 3), "timer" : 20 } + ], + "shoot_B" : [ + { "sprite" : (8, 4), "timer" : 44 }, + { "sprite" : (11, 3), "timer" : 20 } + ], + "hurt_L" : [ + { "sprite" : (1, 4), "timer" : -1 } + ], + "hurt_R" : [ + { "sprite" : (5, 4), "timer" : -1 } + ], + "hurt_B" : [ + { "sprite" : (9, 4), "timer" : -1 } + ], + "activate_L" : [ + { "sprite" : (2, 4), "timer" : -1 } + ], + "activate_R" : [ + { "sprite" : (6, 4), "timer" : -1 } + ], + "activate_B" : [ + { "sprite" : (10, 4), "timer" : -1 } + ], } } diff --git a/src/interface.py b/src/interface.py @@ -1,4 +1,5 @@ import pygame +from . import images class Interface(object): """ @@ -11,12 +12,26 @@ class Interface(object): def handle_events(self): for event in pygame.event.get(): - if event.type == pygame.QUIT: self.game.toggle_on() + elif event.type == pygame.KEYDOWN: + self.handle_key_press(event.key) def handle_key_press(self, key): - pass + if key == pygame.K_LEFT: + self.game.anim_index -= 1 + if self.game.anim_index < 0: + self.game.anim_index = self.game.anim_index_max + for i, k in enumerate(images.ANIMATIONS["jisella_1"]): + if i == self.game.anim_index: + self.game.testvgo.set_animation(images.ANIMATIONS["jisella_1"][k], True, 0) + elif key == pygame.K_RIGHT: + self.game.anim_index += 1 + if self.game.anim_index > self.game.anim_index_max: + self.game.anim_index = 0 + for i, k in enumerate(images.ANIMATIONS["jisella_1"]): + if i == self.game.anim_index: + self.game.testvgo.set_animation(images.ANIMATIONS["jisella_1"][k], True, 0) def handle_key_release(self, key): pass diff --git a/src/vgo.py b/src/vgo.py @@ -31,7 +31,7 @@ class VisibleGameObject(pygame.sprite.Sprite): if self.animation_timer > 0: self.animation_timer -= 1 - else: + elif self.animation_timer == 0: if self.current_animation_frame < len(self.animation) - 1: self.current_animation_frame += 1 else: