Return to repo list

heart-of-gold

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

commit 022794c75ebcebd7f9e267d58f0c5b0feb189672
parent dc28af9a5facc964f82e2564b10b89526d262a7d
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed, 18 Nov 2020 19:16:29 -0600

added target-side damage calc and damage anim

Diffstat:
Mdata/img/facing_arrows_1.png | 0
Mdata/json/anims.json | 408++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mmain.py | 7+++++++
Msrc/interface.py | 7+++++--
Msrc/piece.py | 54++++++++++++++++++++++++++++++++++++++++++------------
5 files changed, 458 insertions(+), 18 deletions(-)

diff --git a/data/img/facing_arrows_1.png b/data/img/facing_arrows_1.png Binary files differ. diff --git a/data/json/anims.json b/data/json/anims.json @@ -87,7 +87,107 @@ { "sprite" : [1, 3], "timer" : 20 }, { "sprite" : [2, 3], "timer" : 4 }, { "sprite" : [3, 3], "timer" : 60 } - ] + ], + "hurt_L" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_R" : [ + { "sprite" : [6, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [4, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [4, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_U" : [ + { "sprite" : [10, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [8, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [8, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_D" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ] }, "jisella_2" : { "stand_L" : [ @@ -177,7 +277,107 @@ { "sprite" : [1, 3], "timer" : 20 }, { "sprite" : [2, 3], "timer" : 4 }, { "sprite" : [3, 3], "timer" : 60 } - ] + ], + "hurt_L" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_R" : [ + { "sprite" : [6, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [4, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [4, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_U" : [ + { "sprite" : [10, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [8, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [8, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_D" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ] }, "jisella_3" : { "stand_L" : [ @@ -267,7 +467,107 @@ { "sprite" : [1, 3], "timer" : 20 }, { "sprite" : [2, 3], "timer" : 4 }, { "sprite" : [3, 3], "timer" : 60 } - ] + ], + "hurt_L" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_R" : [ + { "sprite" : [6, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [4, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [4, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_U" : [ + { "sprite" : [10, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [8, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [8, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_D" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ] }, "jisella_4" : { "stand_L" : [ @@ -357,7 +657,107 @@ { "sprite" : [1, 3], "timer" : 20 }, { "sprite" : [2, 3], "timer" : 4 }, { "sprite" : [3, 3], "timer" : 60 } - ] + ], + "hurt_L" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_R" : [ + { "sprite" : [6, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 4], "timer" : 2 }, + { "sprite" : [4, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [4, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [5, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [6, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [7, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_U" : [ + { "sprite" : [10, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 4], "timer" : 2 }, + { "sprite" : [8, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [8, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [9, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [10, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [11, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ], + "hurt_D" : [ + { "sprite" : [2, 4], "timer" : 30 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 4], "timer" : 2 }, + { "sprite" : [0, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 0], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [0, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [1, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [2, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 }, + { "sprite" : [3, 1], "timer" : 2 }, + { "sprite" : [3, 5], "timer" : 2 } + ] }, "cursor1" : { "pulse" : [ diff --git a/main.py b/main.py @@ -18,6 +18,13 @@ from src import game # for sheets and animations are looking like they will be very common). The 'pictures' directory should maybe be renamed to 'chars' or something. # Scene character art could also be stored in this dir, but scene def JSONs will still just point to specific files (already should support # subdir pathing at this point since it is loaded with os.join). +# 8. BoardManager has specialized methods for creating and finding different kinds of overlay entities, but these entities are differentiated only +# by the custom_flags vals. There should be a universal method for creating overlay entities, which you pass values to to determine their +# custom_flags and images, as well as a universal method for fetching entities from the overlay list. Functionally, moving and attacking are +# the same as far as the BoardManager and its overlay, so generalizing this method will probably be very useful when implementing tactics. +# 9. Animations should not be image-file-specific. Rather, a field should be added to sheets.json entries called "anim" which will point to a +# specific entry in the anims.json file. These entries can then be generalized for entire classes of spritesheets (in particular for piece sprite +# sheets). This will require a rewrite of anims.json and a modification to the sheet manager. # Initialization of pygame and submodules pygame.mixer.pre_init(44100, -16, 4, 1024) diff --git a/src/interface.py b/src/interface.py @@ -164,7 +164,7 @@ class GameInterface(subsystem.GameSubsystem): ap.facing = FACE_DIR.L else: ap.facing = FACE_DIR.R - elif abs(diff[1]) >= abs(diff[0]): + else: if diff[1] >= 0: ap.facing = FACE_DIR.U else: @@ -175,6 +175,7 @@ class GameInterface(subsystem.GameSubsystem): if tilepos != None: self.bus.perform_position_tile_cursor((tilepos[0], tilepos[1])) + # Scroll camera if self.game.control_mode in (CTRL_MODES.Turn_Normal, CTRL_MODES.Turn_Select_Move, CTRL_MODES.Turn_Select_Attack): for r in self.camera.scroll_rects: if self.camera.scroll_rects[r].collidepoint(mouseraw) and pygame.mouse.get_focused(): @@ -189,5 +190,7 @@ class GameInterface(subsystem.GameSubsystem): # Watching an attack complete elif self.game.control_mode == CTRL_MODES.Turn_Watch_Attack: ap = self.bus.fetch("turn_manager", "active_piece") - if not ap.attacking: + if not ap.attacking and not ap.attack_target.being_damaged: + # NOTE: attack target dropped here for timing reasons, a bit hacky... + ap.attack_target = None self.game.control_mode = CTRL_MODES.Turn_Normal diff --git a/src/piece.py b/src/piece.py @@ -245,6 +245,9 @@ class Piece(entity.Entity): self.attacking = False self.attack_target = None self.attack_anim_timer = 0 + self.being_damaged = False + self.damage_timer = 0 + self.damage_to_receive = 0 self.has_moved = False self.has_acted = False self.health_bar = None @@ -342,7 +345,7 @@ class Piece(entity.Entity): self.facing = FACE_DIR.L else: self.facing = FACE_DIR.R - elif abs(diff[1]) >= abs(diff[0]): + else: if diff[1] >= 0: self.facing = FACE_DIR.U else: @@ -356,6 +359,18 @@ class Piece(entity.Entity): self.attack_target = target self.attack_anim_timer = 90 + # Tell the other guy to be damaged + dam = self.active_stats["ATK"] * 2 - self.attack_target.active_stats["DEF"] # TODO: Obv not perm + self.attack_target.set_be_damaged_action(dam) + + def set_be_damaged_action(self, damage): + """ + Setup the action of being damaged. + """ + self.damage_to_receive = damage + self.damage_timer = 100 + self.being_damaged = True + def create_health_bar(self): """ Create a health bar to be displayed along with this piece @@ -435,26 +450,41 @@ class Piece(entity.Entity): else: self.attacking = False self.has_acted = True - # TODO: A 'be_damaged()' method would be appropriate - dam = self.active_stats["ATK"] * 2 # TODO: Obv not perm - self.attack_target.active_stats["HP"] -= dam - if self.attack_target.active_stats["HP"] <= 0: - self.manager.kill_piece(self.attack_target) - self.manager.bus.perform_turn_manager_kill_piece(self.attack_target) + self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) + + def execute_be_damaged(self): + """ + Execute the action of being damaged. + """ + if self.being_damaged: + if self.damage_timer > 0: + self.damage_timer -= 1 + # TODO: This is a bit hacky, but it looks better + if self.damage_timer == 72: + self.set_animation(self.manager.bus.fetch("sheet_manager", "animations")[self.sheet.name]["hurt_" + self.facing.name], True) + elif self.damage_timer == 30: + self.active_stats["HP"] -= self.damage_to_receive + if self.active_stats["HP"] > 0: + self.create_health_bar() + else: + self.being_damaged = False + self.damage_to_receive = 0 + if self.active_stats["HP"] <= 0: + self.manager.kill_piece(self) + self.manager.bus.perform_turn_manager_kill_piece(self) else: - self.attack_target.create_health_bar() + self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) self.manager.bus.perform_turn_manager_refresh_state() - self.attack_target = None - self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) def act(self): """ Overwriting basic act mode. """ - # TODO: Something else should be done so that this doesn't overwrite other - # legit non-walking, non-standing anims. THIS MAY NOT BE THE BEST. self.execute_tile_path_move() self.execute_attack_action() + self.execute_be_damaged() + # TODO: Something else should be done so that this doesn't overwrite other + # legit non-walking, non-standing anims. THIS MAY NOT BE THE BEST. if self.back_to_stand: self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) self.back_to_stand = False