AI_PROJECT/App.py

70 lines
1.7 KiB
Python

import pygame
import Colors
import Tractor
import Pole
import time
import displayControler as dCon
import Image
import Osprzet
import Ui
pygame.init()
show_console=True
screen = pygame.display.set_mode((dCon.getScreenWidth(show_console), dCon.getScreenHeihgt()))
FPS=5
clock=pygame.time.Clock()
image_loader=Image.Image()
image_loader.load_images()
pole=Pole.Pole(screen,image_loader)
pole.draw_grid() #musi byc tutaj wywołane ponieważ inicjalizuje sloty do slownika
ui=Ui.Ui(screen)
#Tractor creation
traktor_slot = pole.get_slot_from_cord((0, 0))
traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.plug,clock)
def init_demo(): #Demo purpose
old_info=""
traktor.draw_tractor()
time.sleep(2)
pole.randomize_colors()
traktor.draw_tractor()
start_flag=True
while True:
clock.tick(FPS)
if(start_flag):
ui.render_text_to_console(string_to_print="Przejazd inicjalizujacy- traktor sprawdza poziom nawodnienia")
traktor.initial_move(pole)
traktor.reset_pos(pole)
start_flag=False
demo_move()
old_info=get_info(old_info)
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
def init(demo):
pygame.display.update()
if(demo==True):
init_demo()
#TODO: Implement
def demo_move():
current_slot = traktor.slot
if current_slot:
current_slot.redraw_image() # Przerysowanie obrazu dla aktualnego slotu
traktor.random_move(pole)
def get_info(old_info):
(x,y)=pygame.mouse.get_pos()
new_info=pole.check_collision(x,y)
if(old_info!=new_info):
print(new_info)
return new_info