AI_PRO/drawUI.py
2021-03-28 22:55:01 +02:00

36 lines
1.2 KiB
Python

from Main.constants import *
import pygame
def drawUI(board, display, tractor_horizontal_index, tractor_vertical_index):
display.fill(WHITE)
makeField(board, display)
drawTractor(display, tractor_horizontal_index, tractor_vertical_index)
pygame.display.update()
def makeField(board, display):
color = BLACK
for i in range(int(HORIZONTAL_TILES_NUMBER)):
for j in range(int(VERTICAL_TILES_NUMBER)):
field = board[i][j]
if field.state == 0:
color = WHITE
elif field.state == 1:
color = RED
elif field.state == 2:
color = YELLOW
elif field.state == 3:
color = GREEN
elif field.state == 4:
color = BLACK
pygame.draw.rect(display, color,
[i * TILE_SIZE, j * TILE_SIZE, TILE_SIZE, TILE_SIZE])
def drawTractor(display, tractor_horizontal_index, tractor_vertical_index):
pygame.draw.rect(display, BLACK,
[tractor_horizontal_index * TILE_SIZE, tractor_vertical_index * TILE_SIZE, TRACTOR_WIDTH,
TRACTOR_HEIGHT])