Projekt_AI-Automatyczny_saper/Engine/Board.py

27 lines
938 B
Python
Raw Normal View History

2021-03-13 21:16:35 +01:00
import pygame
2021-03-15 19:58:20 +01:00
from Constants import ROWS, COLS, SQUARE_SIZE, GREEN, BLACK, WIDTH
2021-03-13 21:16:35 +01:00
class Board:
2021-03-16 18:53:26 +01:00
2021-03-13 21:16:35 +01:00
def __init__(self):
self.board = []
2021-03-15 19:58:20 +01:00
def drawSquares(self, win):
2021-03-13 21:16:35 +01:00
win.fill(GREEN)
for row in range(ROWS):
for col in range(COLS):
2021-03-15 19:04:51 +01:00
pygame.draw.rect(win, BLACK, pygame.Rect(row * SQUARE_SIZE, col * SQUARE_SIZE, SQUARE_SIZE, SQUARE_SIZE), 2)
2021-03-15 19:58:20 +01:00
def drawAgent(self, win, agent):
2021-03-16 18:53:26 +01:00
rect = agent.image.get_rect()
rect.center = (agent.x * SQUARE_SIZE + SQUARE_SIZE / 2, agent.y * SQUARE_SIZE + SQUARE_SIZE / 2 - 5)
win.blit(agent.image, rect)
def drawBombs(self,win, x, y):
image = pygame.image.load('Engine/bomb.png')
image = pygame.transform.scale(image, (SQUARE_SIZE, SQUARE_SIZE))
rect = image.get_rect()
rect.center = (x * SQUARE_SIZE + SQUARE_SIZE/2 + 5, y * SQUARE_SIZE + SQUARE_SIZE/2 - 5)
win.blit(image, rect)