Merge pull request #10 from n0remac/map

Map PR first
This commit is contained in:
Cameron
2020-04-18 19:37:32 -07:00
committed by GitHub
6 changed files with 80 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ verify_ssl = true
[packages]
arcade = "*"
networkx = "*"
[requires]
python_version = "3.7"

View File

@@ -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",

View File

@@ -1,5 +1,14 @@
"""
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
import arcade
class Dungeon(object):
"""
Organizes Level objects into an easy to render and path through object.
@@ -13,7 +22,18 @@ 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
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):
@@ -23,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:
@@ -35,3 +70,9 @@ class Level(object):
:return: The new generated Level file.
"""
pass
def render(self) -> None:
"""
Calls render on all sprites.
"""
pass

View File

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,19 @@
{
"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"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["e", " ", " ", " ", " ", " ", " ", " ", " ", "e"],
["e", " ", " ", " ", " ", " ", " ", " ", " ", "e"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", "w", "w", "w", "e", "e", "w", "w", "w", "w"]
]
}