Poprawiona wersja
This commit is contained in:
parent
bc7d12320b
commit
1803de05c5
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
16
config.py
16
config.py
@ -32,14 +32,24 @@ images_names = ['gleba_pix.png','gleba_chwasty_pix.png','sadzonka_suchi_pix.png'
|
||||
images = []
|
||||
for i in images_names:
|
||||
images.append(pygame.image.load('images/'+i))
|
||||
traktor_img = pygame.image.load('images/traktor.png')
|
||||
##########################################
|
||||
##########Początkowe ustawienia###########
|
||||
|
||||
|
||||
def mat_val(traktor_poz,value):
|
||||
POLE_STAN[traktor_poz[0],traktor_poz[1]]+=value
|
||||
|
||||
|
||||
class img:
|
||||
traktor = ["traktor_d.png","traktor_l.png","traktor_u.png","traktor_r.png"]
|
||||
turn = 0
|
||||
def traktor_get(self):
|
||||
return self.traktor[self.turn]
|
||||
|
||||
def traktor_turn(self, turn):
|
||||
self.turn = turn
|
||||
|
||||
traktor = img()
|
||||
|
||||
|
||||
class activities:
|
||||
modes = ["Nawadnianie", "Odchwaszczanie", "Sadzenie", "Zbiory"]
|
||||
mode = 0
|
||||
|
22
functions.py
22
functions.py
@ -23,12 +23,8 @@ def pressed(key, traktor_poz):
|
||||
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]:
|
||||
@ -40,7 +36,8 @@ def move_left():
|
||||
pass
|
||||
else:
|
||||
config.TRAKTOR_POZ[0]-=70
|
||||
config.ILE_RUCHOW = 21
|
||||
print("Ruch w lewo")
|
||||
config.traktor.traktor_turn(1)
|
||||
return 1
|
||||
|
||||
|
||||
@ -49,6 +46,8 @@ def move_up():
|
||||
pass
|
||||
else:
|
||||
config.TRAKTOR_POZ[1]-=70
|
||||
print("Ruch w górę")
|
||||
config.traktor.traktor_turn(2)
|
||||
return 1
|
||||
|
||||
|
||||
@ -58,36 +57,43 @@ def move_right():
|
||||
pass
|
||||
else:
|
||||
config.TRAKTOR_POZ[0]+=70
|
||||
config.traktor.traktor_turn(3)
|
||||
print("Ruch w prawo")
|
||||
return 1
|
||||
def move_down():
|
||||
if config.TRAKTOR_POZ[1]==705:
|
||||
pass
|
||||
else:
|
||||
config.TRAKTOR_POZ[1]+=70
|
||||
config.traktor.traktor_turn(0)
|
||||
print("Ruch w dół")
|
||||
return 1
|
||||
|
||||
|
||||
def work(traktor_poz):
|
||||
if config.activity.activity_get_value()==0:
|
||||
water(traktor_poz)
|
||||
print("Podlanie pola")
|
||||
|
||||
if config.activity.activity_get_value()==1:
|
||||
weeds(traktor_poz)
|
||||
print("Odchwaszczenie pola")
|
||||
|
||||
if config.activity.activity_get_value()==2:
|
||||
plant(traktor_poz)
|
||||
print("Zasadzenie pola")
|
||||
|
||||
if config.activity.activity_get_value()==3:
|
||||
harvest(traktor_poz)
|
||||
|
||||
print("Zbiory z pola")
|
||||
|
||||
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)
|
||||
if config.POLE_STAN[position[0], position[1]] in [1,3,5,7]:
|
||||
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)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1015 B |
BIN
images/traktor_d.png
Normal file
BIN
images/traktor_d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
images/traktor_l.png
Normal file
BIN
images/traktor_l.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1017 B |
BIN
images/traktor_r.png
Normal file
BIN
images/traktor_r.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1007 B |
BIN
images/traktor_u.png
Normal file
BIN
images/traktor_u.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
1
main.py
1
main.py
@ -64,6 +64,7 @@ while True:
|
||||
for i in range(0,700,70):
|
||||
for j in range(0,700,70):
|
||||
pole_surf.blit(images[POLE_STAN[int(i/70),int(j/70)]],(j,i))
|
||||
traktor_img = pygame.image.load('images/'+traktor.traktor_get())
|
||||
okno.blit(traktor_img, TRAKTOR_POZ)
|
||||
#aktualizacja okna i wyświetlenie
|
||||
pygame.display.update()
|
Loading…
Reference in New Issue
Block a user