2024-03-11 13:24:12 +01:00
|
|
|
import pygame
|
|
|
|
import random
|
2024-03-11 21:24:16 +01:00
|
|
|
import displayControler as dCon
|
|
|
|
import Slot
|
2024-03-11 13:24:12 +01:00
|
|
|
|
|
|
|
class Tractor:
|
|
|
|
def __init__(self,x_axis,y_axis,screen):
|
|
|
|
self.x_axis=x_axis
|
|
|
|
self.y_axis=y_axis
|
|
|
|
self.tractor_image = pygame.image.load('images/traktor.png')
|
2024-03-11 21:24:16 +01:00
|
|
|
self.tractor_image = pygame.transform.scale(self.tractor_image, (dCon.CUBE_SIZE, dCon.CUBE_SIZE))
|
2024-03-11 13:24:12 +01:00
|
|
|
self.screen=screen
|
|
|
|
self.slot=None
|
|
|
|
|
|
|
|
def draw_tractor(self):
|
2024-03-11 21:24:16 +01:00
|
|
|
self.screen.blit(self.tractor_image, (self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE))
|
2024-03-11 13:24:12 +01:00
|
|
|
pygame.display.update()
|
|
|
|
|
|
|
|
def move_tractor(self,x):
|
|
|
|
if(x==0):
|
2024-03-11 21:24:16 +01:00
|
|
|
if(dCon.isValidMove(self.x_axis + 1, self.y_axis)):
|
2024-03-11 13:24:12 +01:00
|
|
|
print("Ruch w prawo")
|
|
|
|
self.x_axis=self.x_axis+1
|
2024-03-11 21:24:16 +01:00
|
|
|
elif(x==1):
|
|
|
|
if(dCon.isValidMove(self.x_axis - 1, self.y_axis)):
|
2024-03-11 13:24:12 +01:00
|
|
|
print("Ruch w lewo")
|
|
|
|
self.x_axis=self.x_axis-1
|
2024-03-11 21:24:16 +01:00
|
|
|
elif(x==2):
|
|
|
|
if(dCon.isValidMove(self.x_axis, self.y_axis + 1)):
|
2024-03-11 13:24:12 +01:00
|
|
|
print("Ruch w dol")
|
2024-03-11 21:24:16 +01:00
|
|
|
self.y_axis=self.y_axis+1
|
|
|
|
elif(x==3):
|
|
|
|
if(dCon.isValidMove(self.x_axis, self.y_axis - 1)):
|
|
|
|
print("Ruch w gore")
|
2024-03-11 13:24:12 +01:00
|
|
|
self.y_axis=self.y_axis-1
|
|
|
|
self.draw_tractor()
|
|
|
|
|
|
|
|
|
|
|
|
def random_move(self):
|
|
|
|
x=random.randint(0,3)
|
|
|
|
self.move_tractor(x)
|
|
|
|
|