From e5f19bcd8a385af85a3755f517035c6a6783f7fc Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Apr 2020 02:39:17 -0500 Subject: [PATCH 1/5] add file docstring, minor reformat, levels attribute --- triple-dungeon/map.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/triple-dungeon/map.py b/triple-dungeon/map.py index 52d593b..b7145e9 100644 --- a/triple-dungeon/map.py +++ b/triple-dungeon/map.py @@ -1,5 +1,12 @@ +""" +map.py +Manages everything related to how walls, backgrounds, levels and the entire dungeon is generated. +Pathfinding will also depend on objects here, and is thus integral to it's functionality. +""" + from __future__ import annotations + class Dungeon(object): """ Organizes Level objects into an easy to render and path through object. @@ -13,7 +20,8 @@ class Dungeon(object): :param size: The diameter of the dungeon. Allows for a total of size^2 slots for levels. """ - self.levels, self.size = level_count, size + self.level_count, self.size = level_count, size + self.levels = [[None for y in range(size)] for x in range(size)] # array[x][y] style access class Level(object): From 0e05870d9b3ee58c7565bba090da799ebec7ef75 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Apr 2020 02:46:48 -0500 Subject: [PATCH 2/5] move file structure around, create basic example level file --- .../{ => resources}/images/monsters/skeleton.png | Bin .../{ => resources}/images/tiles/floor_tile.png | Bin triple-dungeon/resources/levels/center1.json | 14 ++++++++++++++ 3 files changed, 14 insertions(+) rename triple-dungeon/{ => resources}/images/monsters/skeleton.png (100%) rename triple-dungeon/{ => resources}/images/tiles/floor_tile.png (100%) create mode 100644 triple-dungeon/resources/levels/center1.json diff --git a/triple-dungeon/images/monsters/skeleton.png b/triple-dungeon/resources/images/monsters/skeleton.png similarity index 100% rename from triple-dungeon/images/monsters/skeleton.png rename to triple-dungeon/resources/images/monsters/skeleton.png diff --git a/triple-dungeon/images/tiles/floor_tile.png b/triple-dungeon/resources/images/tiles/floor_tile.png similarity index 100% rename from triple-dungeon/images/tiles/floor_tile.png rename to triple-dungeon/resources/images/tiles/floor_tile.png diff --git a/triple-dungeon/resources/levels/center1.json b/triple-dungeon/resources/levels/center1.json new file mode 100644 index 0000000..140d0ad --- /dev/null +++ b/triple-dungeon/resources/levels/center1.json @@ -0,0 +1,14 @@ +{ + "structure" : [ + ["w", "w", "w", "w", "e", "e", "w", "w", "w", "w"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["e", " ", " ", " ", " ", " ", " ", " ", " ", "e"], + ["e", " ", " ", " ", " ", " ", " ", " ", " ", "e"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], + ["w", "w", "w", "w", "e", "e", "w", "w", "w", "w"] + ] +} \ No newline at end of file From a28dac4a46427d5dd50ba3ed7b404f88572f286f Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Apr 2020 02:58:55 -0500 Subject: [PATCH 3/5] add level/dungeon rendering methods, start planning out how positions are placed --- triple-dungeon/map.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/triple-dungeon/map.py b/triple-dungeon/map.py index b7145e9..beff019 100644 --- a/triple-dungeon/map.py +++ b/triple-dungeon/map.py @@ -6,6 +6,8 @@ Pathfinding will also depend on objects here, and is thus integral to it's funct from __future__ import annotations +import arcade + class Dungeon(object): """ @@ -23,6 +25,16 @@ class Dungeon(object): self.level_count, self.size = level_count, size self.levels = [[None for y in range(size)] for x in range(size)] # array[x][y] style access + def render(self) -> None: + """ + Calls render on all level + """ + + for column in self.levels: + for level in column: + if level is not None: + level.render() + class Level(object): """ @@ -31,8 +43,23 @@ class Level(object): """ - def __init__(self,) -> None: - self.wallGrid = [] + def __init__(self, level_x: int, level_y: int) -> None: + """ + Initializes the level class. Defaults with no sprites, and no background. + + :param level_x: The level's X position within the Dungeon level matrix. + :param level_y: The level's Y position within the Dungeon level matrix. + """ + + self.x, self.y = level_x, level_y + self.sprites = arcade.SpriteList() + + # Tuples containing the Node positions of where walls, air and entrances are. + # All positions are generated based on the level's X and Y position, so that all points within + # the dungeon can be mapped by a proper pathfinding system. + self.walls = [] + self.air = [] + self.entrances = [] @staticmethod def load_file(path: str) -> Level: @@ -43,3 +70,9 @@ class Level(object): :return: The new generated Level file. """ pass + + def render(self) -> None: + """ + Calls render on all sprites. + """ + pass \ No newline at end of file From 370d611550dc427edf6398edcf6513e03783c17b Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Apr 2020 03:00:02 -0500 Subject: [PATCH 4/5] add elements map to level save structure --- triple-dungeon/resources/levels/center1.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/triple-dungeon/resources/levels/center1.json b/triple-dungeon/resources/levels/center1.json index 140d0ad..ab537a5 100644 --- a/triple-dungeon/resources/levels/center1.json +++ b/triple-dungeon/resources/levels/center1.json @@ -1,4 +1,9 @@ { + "elements" : { + "w" : "resources/images/tiles/wall_tile.png", + " " : "resources/images/tiles/floor_tile.png", + "e" : "" + }, "structure" : [ ["w", "w", "w", "w", "e", "e", "w", "w", "w", "w"], ["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"], From 4cad1d509141b226acedfeac41248723a852d9a4 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 18 Apr 2020 06:26:31 -0500 Subject: [PATCH 5/5] add networkx to Pipfile --- triple-dungeon/Pipfile | 1 + triple-dungeon/Pipfile.lock | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/triple-dungeon/Pipfile b/triple-dungeon/Pipfile index b9bfbc8..4b6f851 100644 --- a/triple-dungeon/Pipfile +++ b/triple-dungeon/Pipfile @@ -7,6 +7,7 @@ verify_ssl = true [packages] arcade = "*" +networkx = "*" [requires] python_version = "3.7" diff --git a/triple-dungeon/Pipfile.lock b/triple-dungeon/Pipfile.lock index 53fd3e1..6d6b49e 100644 --- a/triple-dungeon/Pipfile.lock +++ b/triple-dungeon/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1fb84d532de970edcad0c15ce698c5001fe4d2b12694ae35a682206882b7bfc3" + "sha256": "800f10e10ab907fd0589f880f7c7bbf82acfb39f3450331a1f3bdcdabc8e561d" }, "pipfile-spec": 6, "requires": { @@ -30,6 +30,21 @@ ], "version": "==19.3.0" }, + "decorator": { + "hashes": [ + "sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760", + "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7" + ], + "version": "==4.4.2" + }, + "networkx": { + "hashes": [ + "sha256:cdfbf698749a5014bf2ed9db4a07a5295df1d3a53bf80bf3cbd61edf9df05fa1", + "sha256:f8f4ff0b6f96e4f9b16af6b84622597b5334bf9cae8cf9b2e42e7985d5c95c64" + ], + "index": "pypi", + "version": "==2.4" + }, "numpy": { "hashes": [ "sha256:1598a6de323508cfeed6b7cd6c4efb43324f4692e20d1f76e1feec7f59013448",