53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
import pygame
|
|
from container.constans import WIDTH, HEIGHT, ROWS, COLUMNS, GREEN
|
|
from container.board import Board
|
|
|
|
FPS = 30
|
|
|
|
#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'container\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
|
|
if event.type == pygame.KEYUP:
|
|
if event.key == pygame.K_SPACE: board.next_move()
|
|
|
|
|
|
#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()
|
|
board.draw_squares(WIN)
|
|
board.draw_pieces(WIN)
|
|
board.draw_agent(WIN)
|
|
board.draw_info(WIN)
|
|
|
|
pygame.display.update()
|
|
|
|
pygame.quit()
|
|
|
|
main()
|