SIP/main.py

72 lines
1.4 KiB
Python
Raw Normal View History

2021-03-15 01:02:13 +01:00
import pygame
2021-03-24 00:20:41 +01:00
from container.constans import WIDTH, HEIGHT, ROWS, COLUMNS, GREEN
2021-03-15 01:02:13 +01:00
from container.board import Board
2021-05-14 14:52:55 +02:00
FPS = 18
2021-03-15 01:02:13 +01:00
#creating game window
WIN = pygame.display.set_mode((WIDTH,HEIGHT))
#setting name
pygame.display.set_caption('Forest')
2021-03-24 00:20:41 +01:00
pygame.font.init()
2021-03-15 01:02:13 +01:00
2021-03-24 00:20:41 +01:00
#detective = pygame.image.load(r'container\detective.png')
2021-03-15 01:02:13 +01:00
def main():
2021-03-15 11:14:56 +01:00
2021-03-15 01:02:13 +01:00
run = True
clock = pygame.time.Clock() #for fps
2021-03-24 00:20:41 +01:00
board = Board(0,40,WIDTH,HEIGHT-40)
2021-03-15 01:02:13 +01:00
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
2021-03-15 01:02:13 +01:00
2021-03-22 19:46:24 +01:00
#managing arrow click
2021-03-24 00:20:41 +01:00
2021-03-15 01:02:13 +01:00
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)
2021-05-14 14:52:55 +02:00
2021-03-22 19:46:24 +01:00
2021-03-24 00:20:41 +01:00
#drawing map and detective
WIN.fill(GREEN)
2021-05-14 14:52:55 +02:00
board.update_agent() #update moves and collecting mushrooms
2021-04-27 13:47:29 +02:00
board.grow_mushrooms()
2021-03-15 01:02:13 +01:00
board.draw_squares(WIN)
2021-03-24 00:20:41 +01:00
board.draw_pieces(WIN)
board.draw_agent(WIN)
board.draw_info(WIN)
2021-05-14 14:52:55 +02:00
2021-03-15 01:02:13 +01:00
pygame.display.update()
2021-05-14 14:52:55 +02:00
if key_input[pygame.K_SPACE]:
board.a_starxd()
if(board.agent.rotating==0 and board.agent.moving==0):
board.a_starxd()
2021-03-15 01:02:13 +01:00
pygame.quit()
main()
2021-05-14 14:52:55 +02:00