defuse mechanic added'

This commit is contained in:
barmal4 2021-03-30 23:10:20 +02:00
parent 3472a53f08
commit d97daf6d55
10 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import pygame import pygame
from Constants import ROWS, COLS, SQUARE_SIZE, GREEN, BLACK, WIDTH from Constants import ROWS, COLS, SQUARE_SIZE, GREEN, BLACK, WIDTH
from Engine.Bomb import Bomb
class Board: class Board:
@ -31,3 +32,9 @@ class Board:
rect = image.get_rect() rect = image.get_rect()
rect.center = (key.getX() * SQUARE_SIZE + SQUARE_SIZE / 2, key.getY() * SQUARE_SIZE + SQUARE_SIZE / 2) rect.center = (key.getX() * SQUARE_SIZE + SQUARE_SIZE / 2, key.getY() * SQUARE_SIZE + SQUARE_SIZE / 2)
self.win.blit(image, rect) self.win.blit(image, rect)
def getBomb(self, point):
if point in self.bombMap:
return self.bombMap[point]
return Bomb(0,0,"")

View File

@ -24,6 +24,7 @@ class Game:
self.goingDown = True self.goingDown = True
def update(self): def update(self):
self.agent.defuse(self.board.getBomb(self.agent.getPoint()))
self.board.drawSquares(self.win) self.board.drawSquares(self.win)
self.board.drawBombs() self.board.drawBombs()
self.board.drawAgent(self.win, self.agent) self.board.drawAgent(self.win, self.agent)
@ -46,11 +47,15 @@ class Game:
self.agent.point = point self.agent.point = point
def randomizeObject(self): def randomizeObject(self):
for x in range(10): i = 0
while i < 11:
point = Point(random.randint(0, 7), random.randint(0, 7)) point = Point(random.randint(0, 7), random.randint(0, 7))
if(point.getX() == 0 and point.getY() == 0):
continue;
if point not in self.board.bombMap: if point not in self.board.bombMap:
object = self.pickObject(random.randint(0, 4)) object = self.pickObject(random.randint(0, 4))
self.board.bombMap[point] = object self.board.bombMap[point] = object
i += 1
def pickObject(self, rand): def pickObject(self, rand):
if rand == 0: if rand == 0:

Binary file not shown.