2023-03-22 17:13:24 +01:00
|
|
|
import pygame
|
|
|
|
import random
|
|
|
|
from pygame.math import Vector2
|
2023-03-26 18:19:10 +02:00
|
|
|
import soil
|
|
|
|
|
2023-03-22 17:13:24 +01:00
|
|
|
|
|
|
|
class Blocks:
|
2023-05-08 08:23:04 +02:00
|
|
|
|
2023-03-22 17:13:24 +01:00
|
|
|
def __init__(self, parent_screen,cell_size):
|
|
|
|
self.parent_screen = parent_screen
|
2023-03-22 21:09:00 +01:00
|
|
|
self.flower_image = pygame.image.load(r'resources/flower.png').convert_alpha()
|
|
|
|
self.flower_image = pygame.transform.scale(self.flower_image, (cell_size, cell_size))
|
2023-03-22 17:13:24 +01:00
|
|
|
|
2023-03-22 21:09:00 +01:00
|
|
|
self.stone_image = pygame.image.load(r'resources/stone.png').convert_alpha()
|
|
|
|
self.stone_image = pygame.transform.scale(self.stone_image, (cell_size, cell_size))
|
2023-03-22 17:13:24 +01:00
|
|
|
|
2023-03-22 21:09:00 +01:00
|
|
|
self.leaf_image = pygame.image.load(r'resources/dead.png').convert_alpha()
|
|
|
|
self.leaf_image = pygame.transform.scale(self.leaf_image, (cell_size, cell_size))
|
|
|
|
|
|
|
|
self.alive_leaf_image = pygame.image.load(r'resources/alive.png').convert_alpha()
|
|
|
|
self.alive_leaf_image = pygame.transform.scale(self.alive_leaf_image, (cell_size, cell_size))
|
2023-03-22 17:13:24 +01:00
|
|
|
|
2023-03-27 15:29:06 +02:00
|
|
|
self.fawn_seed_image = pygame.image.load(r'resources/fawn_seed.png').convert_alpha()
|
|
|
|
self.fawn_seed_image = pygame.transform.scale(self.fawn_seed_image, (cell_size, cell_size))
|
|
|
|
|
|
|
|
self.fawn_wheat_image = pygame.image.load(r'resources/fawn_wheat.png').convert_alpha()
|
|
|
|
self.fawn_wheat_image = pygame.transform.scale(self.fawn_wheat_image, (cell_size, cell_size))
|
|
|
|
|
2023-05-08 21:15:37 +02:00
|
|
|
self.red_image = pygame.image.load(r'resources/redBush.png').convert_alpha()
|
|
|
|
self.red_image = pygame.transform.scale(self.red_image, (cell_size, cell_size))
|
2023-03-27 15:29:06 +02:00
|
|
|
|
2023-03-26 18:19:10 +02:00
|
|
|
self.soil = soil.Soil()
|
|
|
|
|
2023-05-08 08:23:04 +02:00
|
|
|
|
2023-03-22 17:13:24 +01:00
|
|
|
def locate_blocks(self, blocks_number, cell_number, body):
|
|
|
|
for i in range(blocks_number):
|
|
|
|
self.x = random.randint(0, cell_number-1)
|
|
|
|
self.y = random.randint(0, cell_number-1)
|
2023-03-22 21:09:00 +01:00
|
|
|
self.pos = [self.x,self.y]
|
2023-03-22 17:13:24 +01:00
|
|
|
body.append(self.pos)
|
2023-03-22 21:09:00 +01:00
|
|
|
#entire_block.update({self.x : 1}) # for now it may lay on each other,
|
|
|
|
#print(entire_block)
|
2023-03-22 17:13:24 +01:00
|
|
|
|
|
|
|
def place_blocks(self, parent_screen, cell_size, body, color): #drawing blocks
|
|
|
|
for block in body:
|
2023-03-22 21:09:00 +01:00
|
|
|
x = int(block[0] * cell_size)
|
|
|
|
y = int(block[1] * cell_size)
|
2023-03-22 17:13:24 +01:00
|
|
|
if color == 'leaf':
|
2023-03-22 21:09:00 +01:00
|
|
|
self.parent_screen.blit(self.leaf_image, (x, y))
|
|
|
|
if color == 'alive':
|
|
|
|
self.parent_screen.blit(self.alive_leaf_image, (x, y))
|
|
|
|
if color == 'stone':
|
|
|
|
self.parent_screen.blit(self.stone_image, (x, y))
|
|
|
|
if color == 'flower':
|
|
|
|
self.parent_screen.blit(self.flower_image, (x, y))
|
2023-03-27 15:29:06 +02:00
|
|
|
if color == 'fawn_seed':
|
|
|
|
self.parent_screen.blit(self.fawn_seed_image, (x, y))
|
|
|
|
if color == 'fawn_wheat':
|
|
|
|
self.parent_screen.blit(self.fawn_wheat_image, (x, y))
|
2023-05-08 21:15:37 +02:00
|
|
|
if color == 'red':
|
|
|
|
self.parent_screen.blit(self.red_image, (x, y))
|
2023-03-27 15:29:06 +02:00
|
|
|
|
|
|
|
|
2023-03-26 18:19:10 +02:00
|
|
|
|
|
|
|
# if color == 'potato':
|
|
|
|
# pass
|
|
|
|
|
|
|
|
def locate_soil(self, name, acidity, irrigation, blocks_number):
|
|
|
|
# for block in blocks_number:
|
|
|
|
self.soil.set_name(name)
|
|
|
|
self.soil.set_irrigation(irrigation)
|
|
|
|
self.soil.set_acidity(acidity)
|
|
|
|
|
|
|
|
def get_soil_info(self):
|
|
|
|
return self.soil
|
2023-03-22 17:13:24 +01:00
|
|
|
|
|
|
|
def draw_lines(self, parent_screen, cell_size): # background lines
|
|
|
|
for i in range(1, 10):
|
|
|
|
pygame.draw.line(self.parent_screen, (228, 253, 227), (cell_size * i, 0), (cell_size * i, parent_screen), 1)
|
|
|
|
pygame.draw.line(self.parent_screen, (228, 253, 227), (0, cell_size * i), (parent_screen, cell_size * i), 1)
|
2023-03-26 18:19:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|