SI_Traktor/main.py

47 lines
1.3 KiB
Python
Raw Normal View History

2020-05-03 16:59:29 +02:00
import pygame, sys
import tractor,pathfinding,field,ui
2020-04-06 18:24:02 +02:00
from pygame.locals import *
2020-05-03 16:59:29 +02:00
pole = field.field()
path = pathfinding.pathfinding()
traktor = tractor.tractor(pole)
UI = ui.game_ui(traktor,pole)
2020-04-06 18:24:02 +02:00
pygame.init()
2020-05-03 16:59:29 +02:00
UI.update()
UI.update()
2020-04-06 18:24:02 +02:00
while True:
for event in pygame.event.get():
if event.type == QUIT:
2020-05-03 16:59:29 +02:00
print("Zamykanie...")
pygame.quit()
sys.exit()
2020-04-06 18:24:02 +02:00
elif event.type == KEYDOWN:
2020-05-03 16:59:29 +02:00
key = pygame.key.get_pressed()
if key[K_d]:
traktor.move_right()
if key[K_s]:
traktor.move_down()
if key[K_a]:
traktor.move_left()
if key[K_w]:
traktor.move_up()
if key[K_SPACE]:
traktor.work()
if key[K_1]:
traktor.set_mode(0)
if key[K_2]:
traktor.set_mode(1)
if key[K_3]:
traktor.set_mode(2)
if key[K_4]:
traktor.set_mode(3)
if key[K_p]:
path.pathfinding(traktor,pole,UI)
if key[K_F10]:
print(traktor.get_poz())
if key[K_F11]:
print(traktor.get_field_value())
UI.update()
UI.update()