Update board

This commit is contained in:
Mfpass1992 2021-03-16 13:47:37 +01:00
parent b877fbaf4e
commit 815f85c78f

View File

@ -27,30 +27,24 @@ class Board:
def draw(self, screen: pygame.Surface): 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 x in range(len(self.__fields)):
for y in range(len(self.__fields[x])): for y in range(len(self.__fields[x])):
obj = self.__fields[x][y] obj = self.__fields[x][y]
i = x * FIELD_SIZE pos_x = x * FIELD_SIZE + FIELD_SIZE//2
j = y * FIELD_SIZE pos_y = y * FIELD_SIZE + FIELD_SIZE//2
if obj == 'grass': if obj == 'grass':
grassrect.size = (size) grassrect.center = (pos_x, pos_y)
grassrect.center = (i, j)
screen.blit(grass, grassrect) screen.blit(grass, grassrect)
if obj == 'corn': if obj == 'corn':
cornrect.size = (size) cornrect.center = (pos_x, pos_y)
cornrect.center = (i, j)
screen.blit(corn, cornrect) screen.blit(corn, cornrect)
if obj == 'sunflower': if obj == 'sunflower':
sunflowerrect.size = (size) sunflowerrect.center = (pos_x, pos_y)
sunflowerrect.center = (i, j)
screen.blit(sunflower, sunflowerrect) screen.blit(sunflower, sunflowerrect)
if obj == 'sand': if obj == 'sand':
sandrect.size = (size) sandrect.center = (pos_x, pos_y)
sandrect.center = (i, j)
screen.blit(sand, sandrect) screen.blit(sand, sandrect)
if obj == 'clay': if obj == 'clay':
clayrect.size = (size) clayrect.center = (pos_x , pos_y)
clayrect.center = (i, j)
screen.blit(clay, clayrect) screen.blit(clay, clayrect)