This commit is contained in:
lechwolowski 2020-05-05 01:49:26 +02:00
parent 72d63e04ae
commit 6fe1829459
3 changed files with 19 additions and 15 deletions

View File

@ -1,12 +1,12 @@
from models.__garbage_collector__ import GarbageCollector
from helpler import Render_Element
from helpler import __render_element__
from config import MAP_WIDTH, MAP_HEIGHT
class GcEnv:
def __init__(self):
self.draw_items = {(x, y): Render_Element(x, y)
self.draw_items = {(x, y): __render_element__(x, y)
for x in range(MAP_WIDTH) for y in range(MAP_HEIGHT)}
self.__gc__ = GarbageCollector(self.draw_items)
self.actions = {

View File

@ -1,22 +1,25 @@
from config import MAP
from models.Road import Road
from models.Grass import Grass
from models.House import House
from config import MAP_HEIGHT, MAP_WIDTH
from models.Trash import Trash
from config import MAP_HEIGHT, MAP_WIDTH, MAP
def Render_Element(x, y):
item = MAP[y][x]
def __render_element__(__x__, __y__):
item = MAP[__y__][__x__]
if item == "Road":
return Road(x, y)
elif item == "Grass":
return Grass(x, y)
elif item == "House":
return House(x, y)
else:
return Trash(x, y, item)
return Road(__x__, __y__)
if item == "Grass":
return Grass(__x__, __y__)
if item == "House":
return House(__x__, __y__)
return Trash(__x__, __y__, item)
def is_within_width(item): return item[0] >= 0 and item[0] < MAP_WIDTH
def is_within_height(item): return item[1] >= 0 and item[1] < MAP_HEIGHT
def is_within_width(item):
return item[0] >= 0 and item[0] < MAP_WIDTH
def is_within_height(item):
return item[1] >= 0 and item[1] < MAP_HEIGHT

View File

@ -39,6 +39,7 @@ def render_game():
pygame.display.flip()
# pylint: disable=no-member
pygame.init()
WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))