This commit is contained in:
Raman Keraz 2021-03-16 13:27:39 +01:00
parent 2eadb299f0
commit b877fbaf4e
4 changed files with 37 additions and 17 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/python3
import pygame
from images import *
from config import *
@ -12,8 +11,9 @@ class Agent:
self.__move = FIELD_SIZE
def draw(self, screen: pygame.Surface):
rect = pygame.Rect(self.__pos_x, self.__pos_y, FIELD_SIZE, FIELD_SIZE)
pygame.draw.rect(screen, C_BLACK, rect)
tractorrect.size = (FIELD_SIZE, FIELD_SIZE)
tractorrect.center = (self.__pos_x + FIELD_SIZE/2, self.__pos_y + FIELD_SIZE/2)
screen.blit(tractor, tractorrect)
def move_up(self):
if self.__pos_y - self.__move >= 0:

View File

@ -27,22 +27,30 @@ class Board:
def draw(self, screen: pygame.Surface):
size = (FIELD_SIZE/HORIZONTAL_NUM_OF_FIELDS, FIELD_SIZE/HORIZONTAL_NUM_OF_FIELDS)
for x in range(len(self.__fields)):
for y in range(len(self.__fields[x])):
obj = self.__fields[x][y]
i = x * FIELD_SIZE
j = y * FIELD_SIZE
if obj == 'grass':
grassrect.center = (x, y)
grassrect.size = (size)
grassrect.center = (i, j)
screen.blit(grass, grassrect)
if obj == 'corn':
cornrect.center = (x, y)
cornrect.size = (size)
cornrect.center = (i, j)
screen.blit(corn, cornrect)
if obj == 'sunflower':
sunflowerrect.center = (x, y)
sunflowerrect.size = (size)
sunflowerrect.center = (i, j)
screen.blit(sunflower, sunflowerrect)
if obj == 'sand':
sandrect.center = (x, y)
sandrect.size = (size)
sandrect.center = (i, j)
screen.blit(sand, sandrect)
if obj == 'clay':
clayrect.center = (x, y)
clayrect.size = (size)
clayrect.center = (i, j)
screen.blit(clay, clayrect)

View File

@ -10,7 +10,7 @@ __all__ = (
# Board settings:
VERTICAL_NUM_OF_FIELDS = 6
HORIZONTAL_NUM_OF_FIELDS = 6
FIELD_SIZE = 64
FIELD_SIZE = 60
WIDTH = HORIZONTAL_NUM_OF_FIELDS * FIELD_SIZE
HEIGHT = VERTICAL_NUM_OF_FIELDS * FIELD_SIZE

View File

@ -1,13 +1,25 @@
import pygame
from config import *
soilType = ('sand','clay', 'soil', 'grass', 'corn', 'sunflower')
soilType = ('sand','clay', 'grass', 'corn', 'sunflower')
tractor = pygame.image.load("resources/tractor.png")
clay = pygame.image.load("resources/clay.png")
sand = pygame.image.load("resources/sand.png")
grass = pygame.image.load("resources/grass.png")
corn = pygame.image.load("resources/corn.png")
sunflower = pygame.image.load("resources/sunflower.png")
tractor_scale = pygame.image.load("resources/tractor.png")
tractor = pygame.transform.scale(tractor_scale, (FIELD_SIZE, FIELD_SIZE))
clay_scale= pygame.image.load("resources/clay.png")
clay = pygame.transform.scale(clay_scale, (FIELD_SIZE, FIELD_SIZE))
sand_scale = pygame.image.load("resources/sand.png")
sand = pygame.transform.scale(sand_scale, (FIELD_SIZE, FIELD_SIZE))
grass_scale = pygame.image.load("resources/grass.png")
grass = pygame.transform.scale(grass_scale, (FIELD_SIZE, FIELD_SIZE))
corn_scale = pygame.image.load("resources/corn.png")
corn = pygame.transform.scale(corn_scale, (FIELD_SIZE, FIELD_SIZE))
sunflower_scale = pygame.image.load("resources/sunflower.png")
sunflower = pygame.transform.scale(sunflower_scale, (FIELD_SIZE, FIELD_SIZE))
tractorrect = tractor.get_rect()
clayrect = clay.get_rect()