2021-03-15 01:02:13 +01:00
|
|
|
import pygame
|
2021-03-15 11:14:56 +01:00
|
|
|
from container.constans import WIDTH, HEIGHT,SQUARE_SIZE,ROWS,COLUMNS
|
2021-03-15 01:02:13 +01:00
|
|
|
from container.board import Board
|
|
|
|
|
|
|
|
FPS = 8
|
|
|
|
|
|
|
|
#creating game window
|
|
|
|
WIN = pygame.display.set_mode((WIDTH,HEIGHT))
|
|
|
|
#setting name
|
|
|
|
pygame.display.set_caption('Forest')
|
|
|
|
|
|
|
|
|
|
|
|
detective =pygame.image.load(r'C:\Users\ledio\Desktop\projekt si\container\detective.png')
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
board = Board()
|
2021-03-15 11:14:56 +01:00
|
|
|
#board.manage_rows_and_col(ROWS,COLUMNS)
|
2021-03-15 01:02:13 +01:00
|
|
|
|
2021-03-15 11:14:56 +01:00
|
|
|
#managing agent location
|
2021-03-15 01:02:13 +01:00
|
|
|
current_column = 0
|
|
|
|
current_row = 0
|
2021-03-15 11:14:56 +01:00
|
|
|
current_piece = board.get_piece(current_row,current_column)
|
|
|
|
current_piece.change_status()
|
2021-03-15 01:02:13 +01:00
|
|
|
|
|
|
|
#calculate desireable location to pixels
|
|
|
|
def claculate_position(x,y):
|
|
|
|
x = SQUARE_SIZE * x
|
|
|
|
y = SQUARE_SIZE * y
|
|
|
|
return [x,y]
|
|
|
|
|
|
|
|
while run:
|
|
|
|
|
|
|
|
clock.tick(FPS)
|
|
|
|
#print(current_column,current_row)
|
|
|
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
run = False
|
|
|
|
|
|
|
|
key_input = pygame.key.get_pressed()
|
|
|
|
if key_input[pygame.K_LEFT] and current_column != 0:
|
|
|
|
current_column -= 1
|
|
|
|
if key_input[pygame.K_UP] and current_row != 0:
|
|
|
|
current_row -= 1
|
2021-03-15 11:14:56 +01:00
|
|
|
if key_input[pygame.K_RIGHT] and current_column != COLUMNS - 1:
|
2021-03-15 01:02:13 +01:00
|
|
|
current_column += 1
|
2021-03-15 11:14:56 +01:00
|
|
|
if key_input[pygame.K_DOWN] and current_row != 6 - 1:
|
2021-03-15 01:02:13 +01:00
|
|
|
current_row += 1
|
2021-03-15 11:14:56 +01:00
|
|
|
|
|
|
|
current_piece.change_status()
|
|
|
|
current_piece = board.get_piece(current_row,current_column)
|
|
|
|
current_piece.change_status()
|
2021-03-15 01:02:13 +01:00
|
|
|
|
|
|
|
board.draw_squares(WIN)
|
|
|
|
WIN.blit(detective, (claculate_position(current_column,current_row)[0], claculate_position(current_column,current_row)[1]))
|
|
|
|
pygame.display.update()
|
|
|
|
|
|
|
|
pygame.quit()
|
|
|
|
|
|
|
|
main()
|