44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
|
import pygame
|
||
|
import Slot
|
||
|
import random
|
||
|
CUBE_SIZE=128
|
||
|
WIDTH = 1024
|
||
|
HEIGHT = 512
|
||
|
|
||
|
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')
|
||
|
self.tractor_image = pygame.transform.scale(self.tractor_image, (CUBE_SIZE, CUBE_SIZE))
|
||
|
self.screen=screen
|
||
|
self.slot=None
|
||
|
|
||
|
def draw_tractor(self):
|
||
|
self.screen.blit(self.tractor_image, (self.x_axis*CUBE_SIZE,self.y_axis*CUBE_SIZE))
|
||
|
pygame.display.update()
|
||
|
|
||
|
def move_tractor(self,x):
|
||
|
if(x==0):
|
||
|
if(self.x_axis+1<=7):
|
||
|
print("Ruch w prawo")
|
||
|
self.x_axis=self.x_axis+1
|
||
|
if(x==1):
|
||
|
if(self.x_axis-1>=0):
|
||
|
print("Ruch w lewo")
|
||
|
self.x_axis=self.x_axis-1
|
||
|
if(x==2):
|
||
|
if(self.y_axis+1<=3):
|
||
|
print("Ruch w gore")
|
||
|
self.y_axis=self.y_axis+1
|
||
|
if(x==3):
|
||
|
if(self.y_axis-1>=0):
|
||
|
print("Ruch w dol")
|
||
|
self.y_axis=self.y_axis-1
|
||
|
self.draw_tractor()
|
||
|
|
||
|
|
||
|
def random_move(self):
|
||
|
x=random.randint(0,3)
|
||
|
self.move_tractor(x)
|
||
|
|