diff --git a/images/pelny_wozek_1_crate.png b/images/pelny_wozek_1_crate.png index a55c1b1..e27b77d 100644 Binary files a/images/pelny_wozek_1_crate.png and b/images/pelny_wozek_1_crate.png differ diff --git a/images/pelny_wozek_2_crates.png b/images/pelny_wozek_2_crates.png index 6cb7103..ab5fc6a 100644 Binary files a/images/pelny_wozek_2_crates.png and b/images/pelny_wozek_2_crates.png differ diff --git a/images/pelny_wozek_full_3_crates.png b/images/pelny_wozek_full_3_crates.png index 849de5d..eb95727 100644 Binary files a/images/pelny_wozek_full_3_crates.png and b/images/pelny_wozek_full_3_crates.png differ diff --git a/wozek.py b/wozek.py index e131ad8..a38cfac 100644 --- a/wozek.py +++ b/wozek.py @@ -3,8 +3,9 @@ import pygame,math from packageList import listOfPackages -class Wozek(): +class Wozek(pygame.sprite.Sprite): def __init__(self): + super().__init__() self.obecnyStan = None # self.x = 55 # self.y = 55 @@ -13,12 +14,14 @@ class Wozek(): self.height = 64 self.width = 64 self.image = pygame.image.load("images/pusty_wozek.png") + self.rect = self.image.get_rect() # Credit: Forklift icons created by Smashicons - Flaticon # https://www.flaticon.com/free-icons/forklift self.__zainicjuj_stan_poczatkowy() def draw(self): ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y)) + # self.update_position(self.obecnyStan.x, self.obecnyStan.y) #storage = ["none"] * 10 storage = [] @@ -38,7 +41,12 @@ class Wozek(): return element else: print("I'm empty!") - + + def update_position(self, x, y): + self.obecnyStan.x = x + self.obecnyStan.y = y + self.rect.topleft = (x, y) + def dynamic_wozek_picture(self): if self.ln == 0: self.image = pygame.image.load("images/pusty_wozek.png") @@ -48,6 +56,8 @@ class Wozek(): self.image = pygame.image.load("images/pelny_wozek_2_crates.png") elif (self.ln == 10): self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png") + + self.rect = self.image.get_rect() def load_package(self): @@ -56,12 +66,21 @@ class Wozek(): if dist <= 50: self.add_element(package) listOfPackages.list.pop() + + def load_packages_collision(self): + pass + # packages_collision = pygame.sprite.spritecollide(self, listOfPackages.package_group, False) + # if packages_collision: + # for package in packages_collision: + # self.add_element(package) + # listOfPackages.list.remove(package) # collision doesn't work, collision always happens + def drop_package(self): package = self.remove_element() if package is not None: - listOfPackages.list.append(package) - package.x = self.obecnyStan.x+50 + package.x = self.obecnyStan.x package.y = self.obecnyStan.y + listOfPackages.list.append(package) def __zainicjuj_stan_poczatkowy(self): from wyszukiwanie import Stan