59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
import pygame
|
|
|
|
from core.board import Board
|
|
from core.constans import WIDTH, HEIGHT, GREEN
|
|
|
|
from core.decision_tree import DecisionTree
|
|
from core.mushroom import Mushroom
|
|
|
|
FPS = 40
|
|
|
|
# creating game window
|
|
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
|
# setting name
|
|
pygame.display.set_caption('Forest')
|
|
pygame.font.init()
|
|
|
|
# detective = pygame.image.load(r'core\detective.png')
|
|
|
|
|
|
def main():
|
|
run = True
|
|
clock = pygame.time.Clock() # for fps
|
|
board = Board(0, 40, WIDTH, HEIGHT - 40)
|
|
|
|
while run:
|
|
clock.tick(FPS)
|
|
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
run = False
|
|
|
|
# managing arrow click
|
|
key_input = pygame.key.get_pressed()
|
|
if key_input[pygame.K_LEFT]: board.agent.rotate(1)
|
|
if key_input[pygame.K_UP]: board.agent.move()
|
|
if key_input[pygame.K_RIGHT]: board.agent.rotate(-1)
|
|
|
|
# drawing map and detective
|
|
WIN.fill(GREEN)
|
|
board.update_agent() # update moves and collecting mushrooms
|
|
board.grow_mushrooms()
|
|
|
|
board.draw_squares(WIN)
|
|
board.draw_pieces(WIN)
|
|
board.draw_agent(WIN)
|
|
board.draw_info(WIN)
|
|
|
|
pygame.display.update()
|
|
|
|
if key_input[pygame.K_SPACE]:
|
|
board.a_starxd()
|
|
|
|
if board.agent.rotating == 0 and board.agent.moving == 0:
|
|
board.a_starxd()
|
|
pygame.quit()
|
|
|
|
|
|
main()
|