diff --git a/DataModels/GC.py b/DataModels/GC.py index b685404..64dac80 100644 --- a/DataModels/GC.py +++ b/DataModels/GC.py @@ -2,5 +2,4 @@ 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 + Cell.__init__(self, x, y, max_rubbish, yellow, green, blue ) \ No newline at end of file diff --git a/DataModels/__pycache__/GC.cpython-36.pyc b/DataModels/__pycache__/GC.cpython-36.pyc index c3ac277..8136c1d 100644 Binary files a/DataModels/__pycache__/GC.cpython-36.pyc and b/DataModels/__pycache__/GC.cpython-36.pyc differ diff --git a/Resources/Maps/map_002.txt b/Resources/Maps/map_002.txt index 19807a0..f55bca5 100644 --- a/Resources/Maps/map_002.txt +++ b/Resources/Maps/map_002.txt @@ -1,6 +1,7 @@ 6 5 +1 0 Y R R R E H E R E R R R H R B R H R E R R R R G -E H E E R H \ No newline at end of file +E H E E R H diff --git a/Resources/Maps/map_003.txt b/Resources/Maps/map_003.txt index b5f82f9..5f24c00 100644 --- a/Resources/Maps/map_003.txt +++ b/Resources/Maps/map_003.txt @@ -1,5 +1,6 @@ 13 4 +3 0 E Y R R R H H R R R E E E H R R H R R R R H R R H E E E R E H E R H R E R R G -H R R E E B R R R H E R H \ No newline at end of file +H R R E E B R R R H E R H diff --git a/Resources/Maps/map_004.txt b/Resources/Maps/map_004.txt index 01a932b..2627a89 100644 --- a/Resources/Maps/map_004.txt +++ b/Resources/Maps/map_004.txt @@ -1,4 +1,5 @@ 12 10 +1 0 Y R R R E H R R R R R E E R E R R E R E H E R H H R R H R R R R R R R E diff --git a/__pycache__/config.cpython-36.pyc b/__pycache__/config.cpython-36.pyc index c4348df..30b86bc 100644 Binary files a/__pycache__/config.cpython-36.pyc and b/__pycache__/config.cpython-36.pyc differ diff --git a/config.py b/config.py index 0ad8430..0b315ab 100644 --- a/config.py +++ b/config.py @@ -4,7 +4,9 @@ CELL_SIZE = 64 FPS = 60 map = open( sys.argv[1], 'r' ) -GRID_WIDTH, GRID_HEIGHT, GC_X, GC_Y = [int(x) for x in map.readline(2).split()] + +GRID_WIDTH, GRID_HEIGHT = [int(x) for x in map.readline().split()] +GC_X, GC_Y = [int(x) for x in map.readline().split()] WINDOW_HEIGHT = GRID_HEIGHT * CELL_SIZE WINDOW_WIDTH = GRID_WIDTH * CELL_SIZE diff --git a/main.py b/main.py index 80e49b0..864acd7 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ import pygame, sys from random import randint -from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS +from config import WINDOW_HEIGHT, WINDOW_WIDTH, GRID_HEIGHT, GRID_WIDTH, HOUSE_CAPACITY, FPS, GC_X, GC_Y from DataModels.Grass import Grass from DataModels.House import House @@ -12,10 +12,11 @@ from DataModels.GC import GC pygame_sprites = pygame.sprite.Group() FPS_CLOCK = pygame.time.Clock() -GAME_WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32) +GAME_WINDOW = pygame.display.set_mode( (WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32) map = open(sys.argv[1], 'r') map.readline() +map.readline() map_objects = [ [ None for y in range(0,GRID_WIDTH)] for x in range(0, GRID_HEIGHT)] @@ -33,8 +34,9 @@ def generate( letter ): i = 0 for y in map.readlines(): for x in y.split(): - x_coord = i % GRID_WIDTH - y_coord = i // GRID_WIDTH + + y_coord = i % GRID_WIDTH + x_coord = (i - y_coord)//GRID_WIDTH yellow, green, blue = [randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2),randint(0, HOUSE_CAPACITY //2)] if x is 'E': @@ -51,16 +53,11 @@ for y in map.readlines(): 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) ) +pygame_sprites.add( GC(GC_X, GC_Y, 2) ) while True: