Male bugfixy
This commit is contained in:
parent
7c88f065eb
commit
86fdd1543f
6
DataModels/GC.py
Normal file
6
DataModels/GC.py
Normal file
@ -0,0 +1,6 @@
|
||||
from DataModels.Cell import Cell
|
||||
|
||||
class GC( Cell ):
|
||||
def __init__( self, x, y, max_rubbish, yellow = 0, green = 0, blue = 0):
|
||||
Cell.__init__(self, x, y, max_rubbish, yellow, green, blue )
|
||||
|
Binary file not shown.
BIN
DataModels/__pycache__/GC.cpython-36.pyc
Normal file
BIN
DataModels/__pycache__/GC.cpython-36.pyc
Normal file
Binary file not shown.
BIN
DataModels/__pycache__/Road.cpython-36.pyc
Normal file
BIN
DataModels/__pycache__/Road.cpython-36.pyc
Normal file
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
2 2
|
||||
E H
|
||||
H B
|
||||
H Y
|
||||
|
@ -7,4 +7,5 @@ H R E H R H E R E
|
||||
R R R R R E R R E
|
||||
E B R H E R R H E
|
||||
E E R R R R E E E
|
||||
E E E E H R R R H
|
||||
E E E E H R R R H
|
||||
3 1
|
||||
|
@ -8,4 +8,4 @@ E E H R E E R R E H R E
|
||||
E R R R R R R H E R R R
|
||||
H R E E R H E E E R E G
|
||||
E R E H R E R R R R R R
|
||||
E R B R R R R E H E E H
|
||||
E R B R R R R E H E E H
|
||||
|
27
main.py
27
main.py
@ -6,6 +6,8 @@ from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_C
|
||||
from DataModels.Grass import Grass
|
||||
from DataModels.House import House
|
||||
from DataModels.Dump import Dump
|
||||
from DataModels.Road import Road
|
||||
from DataModels.GC import GC
|
||||
|
||||
pygame_sprites = pygame.sprite.Group()
|
||||
|
||||
@ -18,18 +20,22 @@ map.readline()
|
||||
map_objects = [ [ None for y in range(0,GRID_WIDTH)] for x in range(0, GRID_HEIGHT)]
|
||||
|
||||
def generate( letter ):
|
||||
key = 'D' if letter in ['B','G','Y'] else letter
|
||||
letter_mapping = {
|
||||
'E': lambda x, y: Grass(x,y),
|
||||
'H': lambda x, y, max_rubbish, yellow, green, blue: House( x, y, max_rubbish, yellow, green, blue ),
|
||||
'B': lambda x, y, max_rubbish, dump_type: Dump( x, y, max_rubbish, dump_type )
|
||||
'D': lambda x, y, max_rubbish, dump_type: Dump( x, y, max_rubbish, dump_type ),
|
||||
'R': lambda x, y: Road(x,y)
|
||||
}
|
||||
return letter_mapping[letter]
|
||||
|
||||
return letter_mapping[key]
|
||||
|
||||
i = 0
|
||||
for y in map.readlines():
|
||||
for x in y.split():
|
||||
x_coord = i%GRID_WIDTH
|
||||
y_coord = i //GRID_HEIGHT
|
||||
x_coord = i % GRID_WIDTH
|
||||
y_coord = i // GRID_WIDTH
|
||||
|
||||
yellow, green, blue = [randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2)]
|
||||
if x is 'E':
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord)
|
||||
@ -37,12 +43,25 @@ for y in map.readlines():
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord, HOUSE_CAPACITY, yellow, green, blue)
|
||||
elif x is 'B':
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord, 100, "Dump_Blue")
|
||||
elif x is 'G':
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord, 100, "Dump_Green")
|
||||
elif x is 'Y':
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord, 100, "Dump_Yellow")
|
||||
elif x is 'R':
|
||||
map_objects[x_coord][y_coord] = generate(x)(x_coord, y_coord)
|
||||
i += 1
|
||||
|
||||
|
||||
print( GRID_WIDTH, GRID_HEIGHT )
|
||||
print( map_objects )
|
||||
|
||||
|
||||
for line in map_objects:
|
||||
for item in line:
|
||||
pygame_sprites.add(item)
|
||||
|
||||
pygame_sprites.add( GC(0,0,2) )
|
||||
|
||||
while True:
|
||||
|
||||
for event in pygame.event.get():
|
||||
|
Loading…
Reference in New Issue
Block a user