diff --git a/DataModels/GC.py b/DataModels/GC.py new file mode 100644 index 0000000..b685404 --- /dev/null +++ b/DataModels/GC.py @@ -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 ) + \ No newline at end of file diff --git a/DataModels/__pycache__/Cell.cpython-36.pyc b/DataModels/__pycache__/Cell.cpython-36.pyc index 1cf07f1..186a46b 100644 Binary files a/DataModels/__pycache__/Cell.cpython-36.pyc and b/DataModels/__pycache__/Cell.cpython-36.pyc differ diff --git a/DataModels/__pycache__/GC.cpython-36.pyc b/DataModels/__pycache__/GC.cpython-36.pyc new file mode 100644 index 0000000..c3ac277 Binary files /dev/null and b/DataModels/__pycache__/GC.cpython-36.pyc differ diff --git a/DataModels/__pycache__/Road.cpython-36.pyc b/DataModels/__pycache__/Road.cpython-36.pyc new file mode 100644 index 0000000..db9525c Binary files /dev/null and b/DataModels/__pycache__/Road.cpython-36.pyc differ diff --git a/Resources/Maps/map_000.txt b/Resources/Maps/map_000.txt index 0cf75ee..c6fbefd 100644 --- a/Resources/Maps/map_000.txt +++ b/Resources/Maps/map_000.txt @@ -1,3 +1,3 @@ 2 2 E H -H B +H Y diff --git a/Resources/Maps/map_001.txt b/Resources/Maps/map_001.txt index 3a0d379..4333db7 100644 --- a/Resources/Maps/map_001.txt +++ b/Resources/Maps/map_001.txt @@ -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 \ No newline at end of file +E E E E H R R R H +3 1 diff --git a/Resources/Maps/map_004.txt b/Resources/Maps/map_004.txt index d0c8747..01a932b 100644 --- a/Resources/Maps/map_004.txt +++ b/Resources/Maps/map_004.txt @@ -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 \ No newline at end of file +E R B R R R R E H E E H diff --git a/main.py b/main.py index b279024..80e49b0 100644 --- a/main.py +++ b/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():