61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
import pygame
|
|
from Environment import Environment
|
|
from Package import Package
|
|
|
|
TILE_SIZE = 50
|
|
|
|
|
|
class Forklift:
|
|
def __init__(self, window):
|
|
self.window = window
|
|
self.image = pygame.image.load('resources/forklift1.png').convert_alpha()
|
|
self.x = 50
|
|
self.y = 350
|
|
self.environment = Environment(self.window)
|
|
self.hasPackage = False
|
|
self.package = Package(self.window)
|
|
self.direction = 1
|
|
|
|
def drawForklift(self):
|
|
self.environment.drawEnviroment()
|
|
self.package.drawPackage()
|
|
self.window.blit(self.image, (self.x, self.y))
|
|
pygame.display.flip()
|
|
|
|
def moveForkliftRight(self):
|
|
self.x += TILE_SIZE
|
|
self.drawForklift()
|
|
|
|
def moveForkliftLeft(self):
|
|
self.x -= TILE_SIZE
|
|
self.drawForklift()
|
|
|
|
def moveForkliftUp(self):
|
|
self.y -= TILE_SIZE
|
|
self.drawForklift()
|
|
|
|
def moveForkliftDown(self):
|
|
self.y += TILE_SIZE
|
|
self.drawForklift()
|
|
|
|
def rotate_forklift_left(self):
|
|
self.direction = (self.direction - 1) % 4
|
|
self.image = pygame.image.load('resources/forklift' + str(self.direction) + '.png').convert_alpha()
|
|
self.drawForklift()
|
|
|
|
def rotate_forklift_right(self):
|
|
self.direction = (self.direction + 1) % 4
|
|
self.image = pygame.image.load('resources/forklift' + str(self.direction) + '.png').convert_alpha()
|
|
self.drawForklift()
|
|
|
|
def forklift_move(self):
|
|
match self.direction:
|
|
case 0:
|
|
self.moveForkliftUp()
|
|
case 1:
|
|
self.moveForkliftRight()
|
|
case 2:
|
|
self.moveForkliftDown()
|
|
case 3:
|
|
self.moveForkliftLeft()
|