Return to repo list

tzed

Simple story-driven open world 2D CRPG.
Return to HMagellan.com

commit 95f1cf6eedc7b5eeac929d91d8e0efffc5cecc3c
parent 3a1be1b5124c0a3cbd131ff38ae3b8ff7d3aee78
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 19 Sep 2021 17:29:25 -0500

added compass

Diffstat:
Mdata/dungeons/testdun1/dungeon.json | 308++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mdata/etc/sheets.json | 4+++-
Adata/images/compass.png | 0
Adata/images/dungeon1_cd.png | 0
Mdata/images/dungeon1_h.png | 0
Mdata/images/party1.png | 0
Msrc/dungeon.py | 7+++++++
Msrc/gamelib.py | 1+
8 files changed, 309 insertions(+), 11 deletions(-)

diff --git a/data/dungeons/testdun1/dungeon.json b/data/dungeons/testdun1/dungeon.json @@ -48,8 +48,8 @@ }, { "North" : { - "ceiling" : [0, 2], - "floor" : [0, 2], + "ceiling" : [0, 0], + "floor" : [0, 1], "l_wall" : [4, 0], "r_wall" : [2, 0], "horizon" : [1, 4], @@ -89,9 +89,9 @@ "North" : { "ceiling" : [0, 2], "floor" : [0, 2], - "l_wall" : [4, 0], + "l_wall" : [0, 0], "r_wall" : [4, 0], - "horizon" : [2, 4], + "horizon" : [0, 4], "pass" : false, "data" : {} }, @@ -100,7 +100,7 @@ "floor" : [0, 1], "l_wall" : [0, 0], "r_wall" : [2, 0], - "horizon" : [1, 1], + "horizon" : [3, 1], "pass" : true, "data" : {} }, @@ -142,7 +142,7 @@ "l_wall" : [0, 0], "r_wall" : [2, 0], "horizon" : [3, 6], - "pass" : false, + "pass" : true, "data" : {} }, "East" : { @@ -164,10 +164,298 @@ "data" : {} } }, - null, - null], - [null, null, null, null], - [null, null, null, null] + { + "North" : { + "ceiling" : [2, 0], + "floor" : [2, 1], + "l_wall" : [0, 0], + "r_wall" : [3, 0], + "horizon" : [0, 4], + "pass" : false, + "data" : {} + }, + "South" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [3, 4], + "pass" : true, + "data" : {} + }, + "East" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [1, 1], + "pass" : true, + "data" : {} + }, + "West" : { + "ceiling" : [1, 0], + "floor" : [1, 1], + "l_wall" : [1, 0], + "r_wall" : [2, 0], + "horizon" : [1, 4], + "pass" : false, + "data" : {} + } + }, + { + "North" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [3, 1], + "pass" : true, + "data" : {} + }, + "South" : { + "ceiling" : [2, 0], + "floor" : [2, 1], + "l_wall" : [0, 0], + "r_wall" : [3, 0], + "horizon" : [0, 4], + "pass" : false, + "data" : {} + }, + "East" : { + "ceiling" : [1, 0], + "floor" : [1, 1], + "l_wall" : [1, 0], + "r_wall" : [2, 0], + "horizon" : [1, 4], + "pass" : false, + "data" : {} + }, + "West" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [1, 1], + "pass" : true, + "data" : {} + } + } + ], + [ + { + "North" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [0, 0], + "r_wall" : [4, 0], + "horizon" : [0, 4], + "pass" : false, + "data" : {} + }, + "South" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [4, 0], + "r_wall" : [2, 0], + "horizon" : [1, 4], + "pass" : false, + "data" : {} + }, + "East" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [2, 7], + "pass" : true, + "data" : {} + }, + "West" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [3, 0], + "pass" : false, + "data" : {} + } + }, + { + "North" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [0, 1], + "pass" : true, + "data" : {} + }, + "South" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [3, 1], + "pass" : true, + "data" : {} + }, + "East" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [3, 4], + "pass" : true, + "data" : {} + }, + "West" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [2, 0], + "pass" : true, + "data" : {} + } + }, + { + "North" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [3, 1], + "pass" : true, + "data" : {} + }, + "South" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [2, 0], + "pass" : true, + "data" : {} + }, + "East" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [2, 0], + "pass" : true, + "data" : {} + }, + "West" : { + "ceiling" : [1, 2], + "floor" : [2, 2], + "l_wall" : [1, 0], + "r_wall" : [3, 0], + "horizon" : [3, 4], + "pass" : true, + "data" : {} + } + }, + { + "North" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [0, 0], + "r_wall" : [4, 0], + "horizon" : [0, 4], + "pass" : false, + "data" : {} + }, + "South" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [4, 0], + "r_wall" : [2, 0], + "horizon" : [1, 4], + "pass" : false, + "data" : {} + }, + "East" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [3, 0], + "pass" : false, + "data" : {} + }, + "West" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [2, 7], + "pass" : true, + "data" : {} + } + } + ], + [ + { + "North" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [0, 0], + "r_wall" : [4, 0], + "horizon" : [0, 4], + "pass" : false, + "data" : {} + }, + "South" : { + "ceiling" : [0, 2], + "floor" : [0, 2], + "l_wall" : [4, 0], + "r_wall" : [2, 0], + "horizon" : [1, 4], + "pass" : false, + "data" : {} + }, + "East" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [1, 1], + "pass" : true, + "data" : {} + }, + "West" : { + "ceiling" : [0, 0], + "floor" : [0, 1], + "l_wall" : [0, 0], + "r_wall" : [2, 0], + "horizon" : [3, 0], + "pass" : false, + "data" : {} + } + }, + { + "North" : { + }, + "South" : { + }, + "East" : { + }, + "West" : { + } + }, + { + "North" : { + }, + "South" : { + }, + "East" : { + }, + "West" : { + } + }, + null + ] ] ] } diff --git a/data/etc/sheets.json b/data/etc/sheets.json @@ -15,5 +15,7 @@ "party1" : [192, 256, false], "dungeon1_fc" : [682, 165, false], "dungeon1_w" : [220, 512, false], - "dungeon1_h" : [242, 182, false] + "dungeon1_h" : [242, 182, false], + "dungeon1_cd" : [32, 32, false], + "compass" : [192, 48, false] } diff --git a/data/images/compass.png b/data/images/compass.png Binary files differ. diff --git a/data/images/dungeon1_cd.png b/data/images/dungeon1_cd.png Binary files differ. diff --git a/data/images/dungeon1_h.png b/data/images/dungeon1_h.png Binary files differ. diff --git a/data/images/party1.png b/data/images/party1.png Binary files differ. diff --git a/src/dungeon.py b/src/dungeon.py @@ -101,6 +101,10 @@ class Dungeon(object): self.dungeon_view.add(DungeonSprite(self.game.sheets[self.sheetname + "_w"].sprites[tuple(workcell["r_wall"])], (self.game.viewport_rect.topleft[0] + 462, self.game.viewport_rect.topleft[1]))) self.dungeon_view.add(DungeonSprite(self.game.sheets[self.sheetname + "_h"].sprites[tuple(workcell["horizon"])], (self.game.viewport_rect.center[0] - 121, self.game.viewport_rect.center[1] - 91))) + # Add overlay elements + self.dungeon_view.add(DungeonSprite(self.game.sheets["compass"].sprites[(0, 0)], (self.game.viewport_rect.center[0] - 96, self.game.viewport_rect.top + 3))) + self.dungeon_view.add(DungeonSprite(self.game.sheets[self.sheetname + "_cd"].sprites[(self.direction, 0)], (self.game.viewport_rect.center[0] - 16, self.game.viewport_rect.top + 12))) + def update_dungeon(self, surface = None): """ Update the dungeon logic and visuals. @@ -111,6 +115,9 @@ class Dungeon(object): # Section 2 - The DungeonSprite class # ####################################### +# TODO: This class, along with some of the stuff in the board.py file and the ui.py file, should probably be split off into a single, generic sprite +# class that lacks tilepos support but has things like color changing. Entity could be a child of this object. + class DungeonSprite(pygame.sprite.Sprite): """ Simple sprite extension for drawing dungeon diff --git a/src/gamelib.py b/src/gamelib.py @@ -52,6 +52,7 @@ OVERLAY_SHEET = SETTINGS_RAW["overlay_sheet"] # Color constants COLORKEY = (255, 0, 255) BASE_COLOR = (255, 255, 255) +COMPASS_NORTH_COLOR = (255, 0, 0) # Modes STATE_MODES = enum.Enum("STATE_MODES", "Main_Menu_Mode Location_Mode Overworld_Mode Dungeon_Mode Battle_Mode")