wozek no longer "pops" when picking up a package

This commit is contained in:
Woj 2023-05-27 23:20:08 +02:00
parent 3167c74e4a
commit 82d1b7088e
4 changed files with 23 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -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