Return to repo list

heart-of-gold

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

commit cfaa285d1750fb2adc60a5872656a9bdfa9af285
parent 5a036048a712748fda0e516233b8619438105b8e
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun,  6 Sep 2020 04:15:03 -0500

cleanup commit last

Diffstat:
Adata/img/testtiles1.png | 0
Adata/json/maps/test1.json | 14++++++++++++++
Adata/json/tiles/testtiles1.json | 26++++++++++++++++++++++++++
Msrc/battlefield.py | 15+++++++--------
Msrc/constants.py | 1+
Msrc/images.py | 5+++++
6 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/data/img/testtiles1.png b/data/img/testtiles1.png Binary files differ. diff --git a/data/json/maps/test1.json b/data/json/maps/test1.json @@ -0,0 +1,14 @@ +{ + "name" : "Test 1", + "width" : 6, + "height" : 6, + "tilesheet" : "testtiles1", + "tilemap" : [ + "aaabbb", + "bbbbbb", + "bbbbbc", + "ccbbcc", + "cccccd", + "cccddd" + ] +} diff --git a/data/json/tiles/testtiles1.json b/data/json/tiles/testtiles1.json @@ -0,0 +1,26 @@ +{ + "name" : "testtiles1", + "image" : "testtiles1.png", + "tiles" : [ + "a" : { + "name" : "grass1", + "tile" : [0, 0], + "passable" : true + }, + "b" : { + "name" : "dirt1", + "tile" : [1, 0], + "passable" : true + }, + "c" : { + "name" : "sand1", + "tile" : [0, 1], + "passable" : true + }, + "d" : { + "name" : "water1", + "tile" : [1, 1], + "passable" : false + } + ] +} diff --git a/src/battlefield.py b/src/battlefield.py @@ -1,4 +1,5 @@ -import pygame +import pygame, json +from .constants import JSON_PATH class Battlefield(object): """ @@ -6,12 +7,10 @@ class Battlefield(object): in. """ - def __init__(self, tilemap_def, entities_def, meta_def): + def __init__(self, map_json): - self.tilemap_definition = tilemap_def - self.entities_definition = entities_def - self.meta_definition = meta_def + self.json = json.load(os.path.join(JSON_PATH, "map", map_json)) - self.tilemap = {} - self.tile_group = pygame.sprite.Group() - self.entity_group = pygame.sprite.Group() + self.name = self.json["name"] + self.map_width = int(self.json["width"]) + self.map_height = int(self.json["height"]) diff --git a/src/constants.py b/src/constants.py @@ -18,3 +18,4 @@ COLORKEY = (255, 0, 255) # Paths DATA_PATH = os.path.join(os.getcwd(), "data") IMG_PATH = os.path.join(DATA_PATH, "img") +JSON_PATH = os.path.join(DATA_PATH, "json") diff --git a/src/images.py b/src/images.py @@ -78,10 +78,15 @@ class Sheet(object): # THIS SHOULD PROBABLY BE IN ITS OWN # # FILE SOMEWHERE!!! # ####################################### +# NOTE: All of this should be in JSON files SHEETS = { "jisella_1" : Sheet("jisella_1.png", (TILE_WIDTH, TILE_HEIGHT), 72) } +TILE_SHEETS = { + "testsheet1" : Sheet("testsheet1.png", (TILE_WIDTH, TILE_HEIGHT), 4) +} + ANIMATIONS = { "jisella_1" : { "stand_L" : [