diff --git a/__pycache__/settings.cpython-310.pyc b/__pycache__/settings.cpython-310.pyc index 6577f19..952eafd 100644 Binary files a/__pycache__/settings.cpython-310.pyc and b/__pycache__/settings.cpython-310.pyc differ diff --git a/src/road.py b/output.txt similarity index 100% rename from src/road.py rename to output.txt diff --git a/settings.py b/settings.py index 916f954..ed0d402 100644 --- a/settings.py +++ b/settings.py @@ -1,8 +1,8 @@ from cmath import sqrt -screen_width=936 -screen_height=936 +screen_width=1200#936 +screen_height=1000#936 SIZE = (screen_width, screen_height) SPECIES=["carrot","potato","beetroot","wheat"] # size in pixels of one tile = 36px/36px @@ -12,6 +12,6 @@ road_coords = [0, 5, 10, 15, 20, 25] field_width = 4 field_height = 4 field_size = field_width*field_height -fields_amount = 26 +fields_amount = 25 directions = {0: 'UP', 90: 'RIGHT', 180: 'DOWN', 270: 'LEFT'} \ No newline at end of file diff --git a/src/Road.py b/src/Road.py new file mode 100644 index 0000000..34eda2f --- /dev/null +++ b/src/Road.py @@ -0,0 +1,9 @@ +from pygame.sprite import Sprite + +class Road(Sprite): + def __init__(self,x,y): + super().__init__() + self.x=x + self.y=y + self.type='Road' + self.cost=200 \ No newline at end of file diff --git a/src/__pycache__/Road.cpython-310.pyc b/src/__pycache__/Road.cpython-310.pyc new file mode 100644 index 0000000..705dffa Binary files /dev/null and b/src/__pycache__/Road.cpython-310.pyc differ diff --git a/src/__pycache__/map.cpython-310.pyc b/src/__pycache__/map.cpython-310.pyc index 8b63f22..ea4355d 100644 Binary files a/src/__pycache__/map.cpython-310.pyc and b/src/__pycache__/map.cpython-310.pyc differ diff --git a/src/map.py b/src/map.py index 1e479a5..8e7afe8 100644 --- a/src/map.py +++ b/src/map.py @@ -4,6 +4,8 @@ from settings import screen_height, screen_width, SIZE, SPECIES, block_size, til from src.Plant import Plant import random from src.Field import Field +from src.Road import Road +import csv def get_type_by_position(fields, x, y): @@ -30,18 +32,26 @@ def get_cost_by_type(plant_type): fields = pygame.sprite.Group() + +world_matrix = [[0 for _ in range(fields_amount+1)] for _ in range(fields_amount+1)] + def drawRoads(screen): #drawing roads: road = pygame.image.load("assets/road.jpeg") road = pygame.transform.scale(road, tile) for x in road_coords: - for block in range(26): + for block in range(int(fields_amount)+1): screen.blit(road, (x*block_size, block * 36)) - fields.add(Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None)) + tmp_field=Field('road', x*block_size, block * 36, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None) + fields.add(tmp_field) + world_matrix[x][block]=Road(x,block) for y in road_coords: - for block in range(26): - screen.blit(road, (block * 36, y*block_size)) - fields.add(Field('road', block * 36, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None)) + for block in range(int(fields_amount)+1): + screen.blit(road, (block * block_size, y*block_size)) + tmp_field=Field('road', block * block_size, y*block_size, None, get_cost_by_type('road'), None, None, None, None, 'road', None, None) + fields.add(tmp_field) + world_matrix[block][y]=Road(block,y) + barn_img = pygame.image.load('assets/barn.png') barn = pygame.transform.scale(barn_img, tile) @@ -52,17 +62,34 @@ def drawRoads(screen): def seedForFirstTime(): plant_group = pygame.sprite.Group() for field in range(fields_amount): - plant = random.choice(SPECIES) + plant_name = random.choice(SPECIES) blocks_seeded_in_field = 0 while (blocks_seeded_in_field < field_size): + x = (((field%5)*((block_size*(field_width+1)))) + ((blocks_seeded_in_field % field_width)*block_size) + ((3/2)*block_size)) y = ((int(field/5)*((block_size*(field_width+1)))) + ((int(blocks_seeded_in_field/field_height))*block_size) + ((3/2)*block_size)) - new_plant = Plant(plant,0, x, y) + + new_plant = Plant(plant_name,0, x, y) blocks_seeded_in_field = blocks_seeded_in_field + 1 plant_group.add(new_plant) - fields.add(Field('field', x-18, y-18, None, get_cost_by_type(plant), None, None, None, None, plant, None, None)) + tmp_field_plant = Field('field', x-18, y-18, None, get_cost_by_type(plant_name), None, None, None, None, plant_name, None, None) + fields.add(tmp_field_plant) + + mx = int((x-18)/36) + my = int((y-18)/36) + world_matrix[mx][my]=tmp_field_plant + + # for i in range(1,4): + # world_matrix[mx][my+i]=tmp_field_plant + #debug + print(world_matrix) + #end of debug + return plant_group +def put_to_matrix(): + return 0 + def return_fields_list(): return fields