96 lines
2.2 KiB
Python
96 lines
2.2 KiB
Python
|
import pygame
|
||
|
import sys
|
||
|
from pygame.locals import *
|
||
|
import config
|
||
|
|
||
|
|
||
|
def quit():
|
||
|
print("Zamykanie...")
|
||
|
pygame.quit()
|
||
|
sys.exit()
|
||
|
|
||
|
|
||
|
def pressed(key, traktor_poz):
|
||
|
if key[K_d]:
|
||
|
return(move_right())
|
||
|
if key[K_s]:
|
||
|
return(move_down())
|
||
|
if key[K_a]:
|
||
|
return(move_left())
|
||
|
if key[K_w]:
|
||
|
return(move_up())
|
||
|
if key[K_SPACE]:
|
||
|
work(traktor_poz)
|
||
|
if key[K_1]:
|
||
|
config.activity.activity_val(0)
|
||
|
print("123")
|
||
|
print(config.activity.activity_get_value())
|
||
|
if key[K_2]:
|
||
|
config.activity.activity_val(1)
|
||
|
print("123")
|
||
|
print(config.activity.activity_get_value())
|
||
|
if key[K_3]:
|
||
|
config.activity.activity_val(2)
|
||
|
if key[K_4]:
|
||
|
config.activity.activity_val(3)
|
||
|
|
||
|
|
||
|
def move_left():
|
||
|
if config.TRAKTOR_POZ[0]==config.POLE_POZ[1]:
|
||
|
pass
|
||
|
else:
|
||
|
config.TRAKTOR_POZ[0]-=70
|
||
|
config.ILE_RUCHOW = 21
|
||
|
return 1
|
||
|
|
||
|
|
||
|
def move_up():
|
||
|
if config.TRAKTOR_POZ[1]==config.POLE_POZ[0]:
|
||
|
pass
|
||
|
else:
|
||
|
config.TRAKTOR_POZ[1]-=70
|
||
|
return 1
|
||
|
|
||
|
|
||
|
|
||
|
def move_right():
|
||
|
if config.TRAKTOR_POZ[0]==705:
|
||
|
pass
|
||
|
else:
|
||
|
config.TRAKTOR_POZ[0]+=70
|
||
|
return 1
|
||
|
def move_down():
|
||
|
if config.TRAKTOR_POZ[1]==705:
|
||
|
pass
|
||
|
else:
|
||
|
config.TRAKTOR_POZ[1]+=70
|
||
|
return 1
|
||
|
|
||
|
|
||
|
def work(traktor_poz):
|
||
|
if config.activity.activity_get_value()==0:
|
||
|
water(traktor_poz)
|
||
|
|
||
|
if config.activity.activity_get_value()==1:
|
||
|
weeds(traktor_poz)
|
||
|
|
||
|
if config.activity.activity_get_value()==2:
|
||
|
plant(traktor_poz)
|
||
|
|
||
|
if config.activity.activity_get_value()==3:
|
||
|
harvest(traktor_poz)
|
||
|
|
||
|
|
||
|
def water(position):
|
||
|
if config.POLE_STAN[position[0],position[1]] in [0,1,2,3]:
|
||
|
config.mat_val([position[0],position[1]],4)
|
||
|
|
||
|
def weeds(position):
|
||
|
if config.POLE_STAN[position[0], position[1]] in [0,2,4,6]:
|
||
|
config.mat_val([position[0], position[1]], 1)
|
||
|
def plant(position):
|
||
|
if config.POLE_STAN[position[0], position[1]] in [0,1,4,5]:
|
||
|
config.mat_val([position[0], position[1]], 2)
|
||
|
def harvest(position):
|
||
|
if config.POLE_STAN[position[0], position[1]] == 8:
|
||
|
config.mat_val([position[0], position[1]], -8)
|