Projekt_AI-Automatyczny_saper/Engine/Board.py

31 lines
1.1 KiB
Python

import pygame
from Constants import ROWS, COLS, SQUARE_SIZE, GREEN, BLACK, WIDTH
class Board:
def __init__(self, win):
self.board = []
self.bombMap = {}
self.win = win
def drawSquares(self, win):
win.fill(GREEN)
for row in range(ROWS):
for col in range(COLS):
pygame.draw.rect(win, BLACK, pygame.Rect(row * SQUARE_SIZE, col * SQUARE_SIZE, SQUARE_SIZE, SQUARE_SIZE), 2)
def drawAgent(self, win, agent):
rect = agent.image.get_rect()
rect.center = (agent.getPoint().getX() * SQUARE_SIZE + SQUARE_SIZE / 2, agent.getPoint().getY() * SQUARE_SIZE + SQUARE_SIZE / 2 - 5)
win.blit(agent.image, rect)
def drawBombs(self):
for key in self.bombMap:
bomb = self.bombMap[key]
image = pygame.image.load('Engine/' + bomb.bombType + '.png')
image = pygame.transform.scale(image, (SQUARE_SIZE - 5, SQUARE_SIZE - 5))
rect = image.get_rect()
rect.center = (key.getX() * SQUARE_SIZE + SQUARE_SIZE/2, key.getY() * SQUARE_SIZE + SQUARE_SIZE/2)
self.win.blit(image, rect)