45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import pygame
|
|
from Constants import SQUARE_SIZE, GREEN, RIGHT, LEFT, UP, DOWN, COLS, ROWS
|
|
from Engine.Board import Board
|
|
from Engine.Agent import Agent
|
|
|
|
class Game:
|
|
def __init__(self, win):
|
|
self._init()
|
|
self.win = win
|
|
|
|
def _init(self):
|
|
self.board = Board()
|
|
self.agent = Agent(0, 0)
|
|
self.turn = GREEN
|
|
self.goingDown = True
|
|
|
|
|
|
|
|
def update(self):
|
|
self.board.drawSquares(self.win)
|
|
self.board.drawBombs(self.win, 1, 1)
|
|
self.board.drawBombs(self.win, 2, 3)
|
|
self.board.drawBombs(self.win, 5, 6)
|
|
self.board.drawAgent(self.win,self.agent)
|
|
pygame.display.update()
|
|
|
|
def move(self):
|
|
if self.goingDown:
|
|
if self.agent.y + 1 < ROWS:
|
|
self.agent.y += 1
|
|
elif self.agent.x + 1 < COLS:
|
|
self.agent.x += 1
|
|
self.goingDown = not self.goingDown
|
|
else:
|
|
if self.agent.y - 1 >= 0:
|
|
self.agent.y -= 1
|
|
elif self.agent.x + 1 < COLS:
|
|
self.agent.x += 1
|
|
self.goingDown = not self.goingDown
|
|
|
|
|
|
|
|
|
|
|