Return to repo list

heart-of-gold

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

commit b0ff63037da59e5f5ee27cee1c5f06d6d367356d
parent 5fda43d1e5860a4dd908cf68416b5e1f391b8edb
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 29 Nov 2020 22:08:05 -0600

new, much more compact anim json style

Diffstat:
Mdata/json/anims.json | 596++-----------------------------------------------------------------------------
Mdata/json/sheets.json | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
Msrc/game.py | 2+-
Msrc/images.py | 29++++++++++++++++++-----------
Msrc/piece.py | 21++++++++++-----------
Msrc/scene.py | 12+++++++-----
6 files changed, 105 insertions(+), 639 deletions(-)

diff --git a/data/json/anims.json b/data/json/anims.json @@ -1,6 +1,6 @@ { - "jisella_1" : { - "stand_L" : [ + "Piece_Unique_1" : { + "stand_L" : [ { "sprite" : [0, 0], "timer" : 4 }, { "sprite" : [1, 0], "timer" : 4 }, { "sprite" : [2, 0], "timer" : 4 }, @@ -31,366 +31,6 @@ { "sprite" : [11, 1], "timer" : 4 } ], "stand_D" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "sprite" : [1, 1], "timer" : 4 }, - { "sprite" : [2, 1], "timer" : 4 }, - { "sprite" : [3, 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_U" : [ - { "sprite" : [8, 2], "timer" : 6 }, - { "sprite" : [9, 2], "timer" : 6 }, - { "sprite" : [10, 2], "timer" : 6 }, - { "sprite" : [11, 2], "timer" : 6 } - ], - "walk_D" : [ - { "sprite" : [0, 2], "timer" : 6 }, - { "sprite" : [1, 2], "timer" : 6 }, - { "sprite" : [2, 2], "timer" : 6 }, - { "sprite" : [3, 2], "timer" : 6 } - ], - "attack_L" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "sprite" : [1, 3], "timer" : 20 }, - { "sprite" : [2, 3], "timer" : 4 }, - { "sprite" : [3, 3], "timer" : 60 } - ], - "attack_R" : [ - { "sprite" : [4, 3], "timer" : 6 }, - { "sprite" : [5, 3], "timer" : 20 }, - { "sprite" : [6, 3], "timer" : 4 }, - { "sprite" : [7, 3], "timer" : 60 } - ], - "attack_U" : [ - { "sprite" : [8, 3], "timer" : 6 }, - { "sprite" : [9, 3], "timer" : 20 }, - { "sprite" : [10, 3], "timer" : 4 }, - { "sprite" : [11, 3], "timer" : 60 } - ], - "attack_D" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "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" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "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_U" : [ - { "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 } - ], - "stand_D" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "sprite" : [1, 1], "timer" : 4 }, - { "sprite" : [2, 1], "timer" : 4 }, - { "sprite" : [3, 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_U" : [ - { "sprite" : [8, 2], "timer" : 6 }, - { "sprite" : [9, 2], "timer" : 6 }, - { "sprite" : [10, 2], "timer" : 6 }, - { "sprite" : [11, 2], "timer" : 6 } - ], - "walk_D" : [ - { "sprite" : [0, 2], "timer" : 6 }, - { "sprite" : [1, 2], "timer" : 6 }, - { "sprite" : [2, 2], "timer" : 6 }, - { "sprite" : [3, 2], "timer" : 6 } - ], - "attack_L" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "sprite" : [1, 3], "timer" : 20 }, - { "sprite" : [2, 3], "timer" : 4 }, - { "sprite" : [3, 3], "timer" : 60 } - ], - "attack_R" : [ - { "sprite" : [4, 3], "timer" : 6 }, - { "sprite" : [5, 3], "timer" : 20 }, - { "sprite" : [6, 3], "timer" : 4 }, - { "sprite" : [7, 3], "timer" : 60 } - ], - "attack_U" : [ - { "sprite" : [8, 3], "timer" : 6 }, - { "sprite" : [9, 3], "timer" : 20 }, - { "sprite" : [10, 3], "timer" : 4 }, - { "sprite" : [11, 3], "timer" : 60 } - ], - "attack_D" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "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" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "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 }, @@ -400,26 +40,6 @@ { "sprite" : [6, 1], "timer" : 4 }, { "sprite" : [7, 1], "timer" : 4 } ], - "stand_U" : [ - { "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 } - ], - "stand_D" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "sprite" : [1, 1], "timer" : 4 }, - { "sprite" : [2, 1], "timer" : 4 }, - { "sprite" : [3, 1], "timer" : 4 } - ], "walk_L" : [ { "sprite" : [0, 2], "timer" : 6 }, { "sprite" : [1, 2], "timer" : 6 }, @@ -439,10 +59,10 @@ { "sprite" : [11, 2], "timer" : 6 } ], "walk_D" : [ - { "sprite" : [0, 2], "timer" : 6 }, - { "sprite" : [1, 2], "timer" : 6 }, - { "sprite" : [2, 2], "timer" : 6 }, - { "sprite" : [3, 2], "timer" : 6 } + { "sprite" : [4, 2], "timer" : 6 }, + { "sprite" : [5, 2], "timer" : 6 }, + { "sprite" : [6, 2], "timer" : 6 }, + { "sprite" : [7, 2], "timer" : 6 } ], "attack_L" : [ { "sprite" : [0, 3], "timer" : 6 }, @@ -463,10 +83,10 @@ { "sprite" : [11, 3], "timer" : 60 } ], "attack_D" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "sprite" : [1, 3], "timer" : 20 }, - { "sprite" : [2, 3], "timer" : 4 }, - { "sprite" : [3, 3], "timer" : 60 } + { "sprite" : [4, 3], "timer" : 6 }, + { "sprite" : [5, 3], "timer" : 20 }, + { "sprite" : [6, 3], "timer" : 4 }, + { "sprite" : [7, 3], "timer" : 60 } ], "hurt_L" : [ { "sprite" : [2, 4], "timer" : 30 }, @@ -544,146 +164,6 @@ { "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" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "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_U" : [ - { "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 } - ], - "stand_D" : [ - { "sprite" : [0, 0], "timer" : 4 }, - { "sprite" : [1, 0], "timer" : 4 }, - { "sprite" : [2, 0], "timer" : 4 }, - { "sprite" : [3, 0], "timer" : 4 }, - { "sprite" : [0, 1], "timer" : 4 }, - { "sprite" : [1, 1], "timer" : 4 }, - { "sprite" : [2, 1], "timer" : 4 }, - { "sprite" : [3, 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_U" : [ - { "sprite" : [8, 2], "timer" : 6 }, - { "sprite" : [9, 2], "timer" : 6 }, - { "sprite" : [10, 2], "timer" : 6 }, - { "sprite" : [11, 2], "timer" : 6 } - ], - "walk_D" : [ - { "sprite" : [0, 2], "timer" : 6 }, - { "sprite" : [1, 2], "timer" : 6 }, - { "sprite" : [2, 2], "timer" : 6 }, - { "sprite" : [3, 2], "timer" : 6 } - ], - "attack_L" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "sprite" : [1, 3], "timer" : 20 }, - { "sprite" : [2, 3], "timer" : 4 }, - { "sprite" : [3, 3], "timer" : 60 } - ], - "attack_R" : [ - { "sprite" : [4, 3], "timer" : 6 }, - { "sprite" : [5, 3], "timer" : 20 }, - { "sprite" : [6, 3], "timer" : 4 }, - { "sprite" : [7, 3], "timer" : 60 } - ], - "attack_U" : [ - { "sprite" : [8, 3], "timer" : 6 }, - { "sprite" : [9, 3], "timer" : 20 }, - { "sprite" : [10, 3], "timer" : 4 }, - { "sprite" : [11, 3], "timer" : 60 } - ], - "attack_D" : [ - { "sprite" : [0, 3], "timer" : 6 }, - { "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 }, @@ -707,59 +187,9 @@ { "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" : { + "Board_Cursor_1" : { "pulse" : [ { "sprite" : [0, 0], "timer" : 3 }, { "sprite" : [1, 0], "timer" : 3 }, @@ -769,7 +199,7 @@ { "sprite" : [1, 0], "timer" : 3 } ] }, - "continue_prompt_1" : { + "Continue_Prompt_1" : { "shimmer" : [ { "sprite" : [0, 0], "timer" : 52 }, { "sprite" : [0, 1], "timer" : 1 }, @@ -782,7 +212,7 @@ { "sprite" : [0, 8], "timer" : 1 } ] }, - "plumb_bob_1" : { + "Plumb_Bob_1" : { "spin" : [ { "sprite" : [0, 0], "timer" : 8 }, { "sprite" : [1, 0], "timer" : 8 }, diff --git a/data/json/sheets.json b/data/json/sheets.json @@ -2,141 +2,169 @@ "mainmenubg" : { "filename" : "mainmenubg.png", "dimensions" : [1024, 768], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "mainmenu_buttons_1" : { "filename" : "mainmenu_buttons_1.png", "dimensions" : [100, 50], - "total_sprites" : 16 + "total_sprites" : 16, + "anim_class" : null }, "still_scene_text_box_1" : { "filename" : "still_scene_text_box_1.png", "dimensions" : [1024, 260], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "still_scene_name_box_1" : { "filename" : "still_scene_name_box_1.png", "dimensions" : [150, 54], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "continue_prompt_1" : { "filename" : "continue_prompt_1.png", "dimensions" : [32, 13], - "total_sprites" : 9 + "total_sprites" : 9, + "anim_class" : "Continue_Prompt_1" }, "test_scene_bg_1" : { "filename" : "test_scene_bg_1.png", "dimensions" : [1024, 768], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "test_scene_char1" : { "filename" : "test_scene_char1.png", "dimensions" : [72, 200], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "jisella_1" : { "filename" : "jisella_1.png", "dimensions" : [64, 64], - "total_sprites" : 72 + "total_sprites" : 72, + "anim_class" : "Piece_Unique_1" }, "jisella_2" : { "filename" : "jisella_2.png", "dimensions" : [64, 64], - "total_sprites" : 72 + "total_sprites" : 72, + "anim_class" : "Piece_Unique_1" }, "jisella_3" : { "filename" : "jisella_3.png", "dimensions" : [64, 64], - "total_sprites" : 72 + "total_sprites" : 72, + "anim_class" : "Piece_Unique_1" }, "jisella_4" : { "filename" : "jisella_4.png", "dimensions" : [64, 64], - "total_sprites" : 72 + "total_sprites" : 72, + "anim_class" : "Piece_Unique_1" }, "jisella_pictures_1_icons_small" : { "filename" : "pictures/jisella_1/icons_small.png", "dimensions" : [24, 24], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "jisella_pictures_2_icons_small" : { "filename" : "pictures/jisella_2/icons_small.png", "dimensions" : [24, 24], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "jisella_pictures_3_icons_small" : { "filename" : "pictures/jisella_3/icons_small.png", "dimensions" : [24, 24], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "jisella_pictures_4_icons_small" : { "filename" : "pictures/jisella_4/icons_small.png", "dimensions" : [24, 24], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "cursor1" : { "filename" : "cursor1.png", "dimensions" : [64, 64], - "total_sprites" : 4 + "total_sprites" : 4, + "anim_class" : "Board_Cursor_1" }, "board_overlays_1" : { "filename" : "board_overlays_1.png", "dimensions" : [64, 64], - "total_sprites" : 4 + "total_sprites" : 4, + "anim_class" : null }, "turn_order_tray_1" : { "filename" : "turn_order_tray_1.png", "dimensions" : [135, 128], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "turn_order_tray_extended_1" : { "filename" : "turn_order_tray_extended_1.png", "dimensions" : [135, 320], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "turn_icon_holder_1" : { "filename" : "turn_icon_holder_1.png", "dimensions" : [128, 28], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "toggle_more_turn_button_1" : { "filename" : "toggle_more_turn_button_1.png", "dimensions" : [135, 14], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "action_buttons_1" : { "filename" : "action_buttons_1.png", "dimensions" : [198, 48], - "total_sprites" : 14 + "total_sprites" : 14, + "anim_class" : null }, "team_indicator_small_1" : { "filename" : "team_indicator_small_1.png", "dimensions" : [12, 12], - "total_sprites" : 2 + "total_sprites" : 2, + "anim_class" : null }, "facing_arrows_1" : { "filename" : "facing_arrows_1.png", "dimensions" : [64, 64], - "total_sprites" : 4 + "total_sprites" : 4, + "anim_class" : null }, "stat_screen_1" : { "filename" : "stat_screen_1.png", "dimensions" : [1024, 768], - "total_sprites" : 1 + "total_sprites" : 1, + "anim_class" : null }, "affinity_icons_1" : { "filename" : "affinity_icons_1.png", "dimensions" : [142, 100], - "total_sprites" : 6 + "total_sprites" : 6, + "anim_class" : null }, "affinity_icons_named_1" : { "filename" : "affinity_icons_named_1.png", "dimensions" : [142, 100], - "total_sprites" : 6 + "total_sprites" : 6, + "anim_class" : null }, "plumb_bob_1" : { "filename" : "plumb_bob_1.png", "dimensions" : [22, 22], - "total_sprites" : 6 + "total_sprites" : 6, + "anim_class" : "Plumb_Bob_1" } } diff --git a/src/game.py b/src/game.py @@ -58,8 +58,8 @@ class Game(object): self.turn_manager = turn.TurnManager(self, self.manager_bus, self.camera, "turn_manager") # Setup (This is WIP) - self.sheet_manager.load_sheets_from_json("sheets.json") self.sheet_manager.load_animations_from_json("anims.json") + self.sheet_manager.load_sheets_from_json("sheets.json") self.sound_manager.load_sounds_from_json("sounds.json") # Switch to game control diff --git a/src/images.py b/src/images.py @@ -42,6 +42,7 @@ class SheetManager(manager.Manager): # Important values self.sheets_def = {} self.loaded_sheets = {} + self.anims_def = {} self.animations = {} # This manager should perform an initial update @@ -49,25 +50,30 @@ class SheetManager(manager.Manager): def load_sheets_from_json(self, sheet_json): """ - Load sheets from the given definition JSON file. + Load sheets from the given definition JSON file. Note + that sheets must be loaded AFTER animations. """ with open(os.path.join(JSON_PATH, sheet_json)) as df: self.sheets_def = json.load(df) for j in self.sheets_def: - self.loaded_sheets[j] = Sheet(self, self.sheets_def[j]["filename"], j, tuple(self.sheets_def[j]["dimensions"]), self.sheets_def[j]["total_sprites"]) + an = {} + if self.sheets_def[j]["anim_class"] != None: + an = self.animations[self.sheets_def[j]["anim_class"]] + self.loaded_sheets[j] = Sheet(self, self.sheets_def[j]["filename"], j, tuple(self.sheets_def[j]["dimensions"]), self.sheets_def[j]["total_sprites"], an) def load_animations_from_json(self, anim_json): """ Load animations from the given definition JSON file. + Note that animations must be loaded BEFORE sheets. """ - with open(os.path.join(JSON_PATH, anim_json)) as anf: self.animations = json.load(anf) + with open(os.path.join(JSON_PATH, anim_json)) as anf: self.anims_def = json.load(anf) - # Make sure the sheet subimage coords are in tuple form - for c in self.animations: - for a in self.animations[c]: - for i in range(0, len(self.animations[c][a])): - for v in self.animations[c][a][i]: - if type(self.animations[c][a][i][v]) == list: - self.animations[c][a][i][v] = tuple(self.animations[c][a][i][v]) + self.animations = self.anims_def + for c in self.anims_def: + for a in self.anims_def[c]: + for i in range(0, len(self.anims_def[c][a])): + for v in self.anims_def[c][a][i]: + if type(self.anims_def[c][a][i][v]) == list: + self.animations[c][a][i][v] = tuple(self.anims_def[c][a][i][v]) def get_sheet(self, name): """ @@ -97,7 +103,7 @@ class Sheet(object): (that is, all sprites are the same dimensions). """ - def __init__(self, manager, filename, name, sprite_size, total_sprites): + def __init__(self, manager, filename, name, sprite_size, total_sprites, animations): # Important values self.manager = manager @@ -106,6 +112,7 @@ class Sheet(object): self.sprite_dimensions = sprite_size self.total_sprites = total_sprites self.sprites = {} + self.animations = animations # Try and load all sprites on the sheet, or log if we failed if not self.load_sheet(filename, sprite_size, total_sprites): diff --git a/src/piece.py b/src/piece.py @@ -60,7 +60,7 @@ class PieceManager(manager.Manager): # are passed to the piece objects. work = copy.deepcopy(definition[p]) n_sheet = self.bus.fetch("sheet_manager", "sheets")[work["sheet"]] - n_anim = self.bus.fetch("sheet_manager", "animations")[work["sheet"]][work["animation"]] + n_anim = n_sheet.animations[work["animation"]] n_name = work["name"] n_class = work["class"] n_pic = work["pictures"] @@ -137,12 +137,11 @@ class PieceManager(manager.Manager): """ try: sh = self.bus.fetch("sheet_manager", "sheets") - an = self.bus.fetch("sheet_manager", "animations") except ManagerBusError: return - self.tile_cursor = TileCursor(sh["cursor1"], (0, 0), an["cursor1"]["pulse"], True) - self.plumb_bob = entity.Entity(sh["plumb_bob_1"], (0, 0), an["plumb_bob_1"]["spin"], True) + self.tile_cursor = TileCursor(sh["cursor1"], (0, 0), sh["cursor1"].animations["pulse"], True) + self.plumb_bob = entity.Entity(sh["plumb_bob_1"], (0, 0), sh["plumb_bob_1"].animations["spin"], True) def get_piece_by_name(self, name): """ @@ -356,7 +355,7 @@ class Piece(entity.Entity): self.taking_turn = False self.haste_mod = 3 # 3 - normal, 1 - minimum (slow 2), 5 - maximum (haste 2) - self.set_animation(self.manager.bus.fetch("sheet_manager", "animations")[self.sheet.name]["stand_" + self.facing.name], True) + self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) def load_pictures(self, pictures): """ @@ -471,7 +470,7 @@ class Piece(entity.Entity): self.facing = FACE_DIR.D # Setup the animation - self.set_animation(self.manager.bus.fetch("sheet_manager", "animations")[self.sheet.name]["attack_" + self.facing.name], True) + self.set_animation(self.sheet.animations["attack_" + self.facing.name], True) # Then, setup attack execution values self.attacking = True @@ -624,7 +623,7 @@ class Piece(entity.Entity): self.facing = FACE_DIR.D if self.facing != oldface or self.first_path_move_pass: - self.set_animation(self.manager.bus.fetch("sheet_manager", "animations")[self.sheet.name]["walk_" + self.facing.name], True) + self.set_animation(self.sheet.animations["walk_" + self.facing.name], True) self.first_path_move_pass = False # Setup motion to next tile in the path @@ -652,7 +651,7 @@ class Piece(entity.Entity): else: self.attacking = False self.has_acted = True - self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) + self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) def execute_be_damaged(self): """ @@ -663,7 +662,7 @@ class Piece(entity.Entity): 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) + self.set_animation(self.sheet.animations["hurt_" + self.facing.name], True) elif self.damage_timer == 30: self.hp_damage_mod -= self.damage_to_receive self.modulate_stats() @@ -683,7 +682,7 @@ class Piece(entity.Entity): self.manager.kill_piece(self) self.manager.bus.perform_turn_manager_kill_piece(self) else: - self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) + self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) self.manager.bus.perform_turn_manager_refresh_state() def modulate_stats(self): @@ -721,7 +720,7 @@ class Piece(entity.Entity): # 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.set_animation(self.sheet.animations["stand_" + self.facing.name], True) self.back_to_stand = False def update(self, surface = None): diff --git a/src/scene.py b/src/scene.py @@ -119,20 +119,22 @@ class StillScene(object): """ Load a scene from file. """ + # Setup + sh = self.manager.bus.fetch("sheet_manager", "sheets") + # Load univeral elements - self.name_box = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")["still_scene_name_box_1"]) + self.name_box = entity.Entity(sh["still_scene_name_box_1"]) self.name_box.set_position(self.name_box_pos) - self.text_box = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")["still_scene_text_box_1"]) + self.text_box = entity.Entity(sh["still_scene_text_box_1"]) self.text_box.set_position(self.text_box_pos) - self.continue_prompt = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")["continue_prompt_1"], (0, 0), - self.manager.bus.fetch("sheet_manager", "animations")["continue_prompt_1"]["shimmer"]) + self.continue_prompt = entity.Entity(sh["continue_prompt_1"], (0, 0), sh["continue_prompt_1"].animations["shimmer"], True) self.continue_prompt.set_position(self.continue_prompt_pos) # Load from scene definition JSON with open(os.path.join(SCENE_JSON_PATH, scenefile)) as df: scenedef = json.load(df) self.name = scenedef["name"] - self.background = entity.Entity(self.manager.bus.fetch("sheet_manager", "sheets")[scenedef["bg_sheet"]], tuple(scenedef["bg_sprite"])) + self.background = entity.Entity(sh[scenedef["bg_sheet"]], tuple(scenedef["bg_sprite"])) self.script = scenedef["script"] for f in scenedef["fonts"]: self.fonts[f] = pygame.font.Font(os.path.join(FONT_PATH, scenedef["fonts"][f][0]), scenedef["fonts"][f][1])