import pygame from Environment import Environment from Package import Package RECT_SIZE = 50 class Truck: def __init__(self, window, ): self.window = window self.image = pygame.image.load("resources/truck.jpeg").convert() self.x = 701 # (x,y) - position of the truck self.y = 401 self.has_package = False self.environment = Environment(window) self.package = Package(self.window) # drawing the truck def draw(self): self.environment.draw_itself() self.package.draw() self.window.blit(self.image, (self.x, self.y)) pygame.display.flip() # moving the truck def move_right(self): self.x += RECT_SIZE self.draw() def move_left(self): self.x -= RECT_SIZE self.draw() def move_up(self): self.y -= RECT_SIZE self.draw() def move_down(self): self.y += RECT_SIZE self.draw() # def collision_with_shelves(self,x,y): # for row in self.environment.compute_coordinates_of_shelves(): # if self.is_collision(x, y,row[0],row[1]): # return True # return False # # def is_collision(self, x1, y1, x2, y2): # if x1 >= x2 and x1 <= x2 + RECT_SIZE: # if y1 >= y2 and y1 <= y2 + 6*RECT_SIZE: # return True #