general refactor/cleanup to get closer to PEP8 standards

This commit is contained in:
Xevion
2020-04-20 01:31:08 -05:00
parent 1338d24edf
commit abf80c1b0f
2 changed files with 28 additions and 20 deletions

View File

@@ -6,9 +6,9 @@ Holds the main game window, as well as manages basic functions for organizing th
import arcade
from config import Config
from map import Dungeon
from mobs import Player, Enemy
from config import Config, Sprites
from mobs import Player
class Game(arcade.Window):
@@ -58,7 +58,6 @@ class Game(arcade.Window):
self.player.center_y = Config.SCREEN_HEIGHT / 2
self.player_list = self.player
# Create the dungeon
dungeon = Dungeon()

View File

@@ -5,12 +5,14 @@ Pathfinding will also depend on objects here, and is thus integral to it's funct
"""
from __future__ import annotations
from config import Config
import json
import arcade
import json
import numpy as np
from config import Config
class Dungeon(object):
"""
@@ -24,7 +26,10 @@ class Dungeon(object):
:param level_count: The number of Active Levels that should be stored within the Dungeon.
:param size: The diameter of the dungeon. Allows for a total of size^2 slots for levels.
"""
# setup
self.level_count = level_count
self.size = size
self.floor_list = arcade.SpriteList()
self.wall_list = arcade.SpriteList()
level_size = 10 * Config.TILE_SCALING * Config.TILE_WIDTH
@@ -43,7 +48,7 @@ class Dungeon(object):
room.load_file('resources/levels/map1/room.json')
room.rotate_level(2)
room.render()
room_floor, room_wall = room.get_lists()
room_floor, room_wall = room.floor_list, room.wall_list
room_floor.move(level_size, 0)
room_wall.move(level_size, 0)
self.floor_list.extend(room_floor)
@@ -53,7 +58,7 @@ class Dungeon(object):
room = Level()
room.load_file('resources/levels/map1/room.json')
room.render()
room_floor, room_wall = room.get_lists()
room_floor, room_wall = room.floor_list, room.wall_list
room_floor.move(-level_size, 0)
room_wall.move(-level_size, 0)
self.floor_list.extend(room_floor)
@@ -112,7 +117,6 @@ class Level:
with open(path) as file:
level = json.load(file)
self.sprites = level['elements']
self.level = level['structure']
@@ -145,6 +149,11 @@ class Level:
return self.floor_list, self.wall_list
def rotate_level(self, times_rotated):
"""
Rotates the
:param times_rotated:
:return:
"""
m = np.array(self.level)
for i in range(0, times_rotated % 4):
m = np.rot90(m)