60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
import pygame
|
|
from Constants import ROWS, COLS, SQUARE_SIZE, GREEN, BLACK, WIDTH, SHORT, LARGE, YES, SMALL
|
|
from Engine.Bomb import Bomb
|
|
|
|
|
|
class Board:
|
|
|
|
def __init__(self, win):
|
|
self.board = []
|
|
self.bombMap = {}
|
|
self.stoneMap = {}
|
|
self.mudMap = {}
|
|
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):
|
|
agent.rotateImage()
|
|
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]
|
|
if not bomb.isDefused:
|
|
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)
|
|
|
|
def drawStones(self):
|
|
for key in self.stoneMap:
|
|
image = pygame.image.load('Engine/stone.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)
|
|
|
|
def drawMud(self):
|
|
for key in self.mudMap:
|
|
image = pygame.image.load('Engine/Mud.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)
|
|
|
|
def getBomb(self, point):
|
|
if point in self.bombMap:
|
|
return self.bombMap[point]
|
|
return Bomb(SHORT,"",LARGE,SMALL, YES)
|
|
|