wozek no longer "pops" when picking up a package
This commit is contained in:
parent
3167c74e4a
commit
82d1b7088e
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 |
27
wozek.py
27
wozek.py
@ -3,8 +3,9 @@ import pygame,math
|
|||||||
from packageList import listOfPackages
|
from packageList import listOfPackages
|
||||||
|
|
||||||
|
|
||||||
class Wozek():
|
class Wozek(pygame.sprite.Sprite):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
self.obecnyStan = None
|
self.obecnyStan = None
|
||||||
# self.x = 55
|
# self.x = 55
|
||||||
# self.y = 55
|
# self.y = 55
|
||||||
@ -13,12 +14,14 @@ class Wozek():
|
|||||||
self.height = 64
|
self.height = 64
|
||||||
self.width = 64
|
self.width = 64
|
||||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
# Credit: Forklift icons created by Smashicons - Flaticon
|
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||||
# https://www.flaticon.com/free-icons/forklift
|
# https://www.flaticon.com/free-icons/forklift
|
||||||
self.__zainicjuj_stan_poczatkowy()
|
self.__zainicjuj_stan_poczatkowy()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
||||||
|
# self.update_position(self.obecnyStan.x, self.obecnyStan.y)
|
||||||
|
|
||||||
#storage = ["none"] * 10
|
#storage = ["none"] * 10
|
||||||
storage = []
|
storage = []
|
||||||
@ -38,7 +41,12 @@ class Wozek():
|
|||||||
return element
|
return element
|
||||||
else:
|
else:
|
||||||
print("I'm empty!")
|
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):
|
def dynamic_wozek_picture(self):
|
||||||
if self.ln == 0:
|
if self.ln == 0:
|
||||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
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")
|
self.image = pygame.image.load("images/pelny_wozek_2_crates.png")
|
||||||
elif (self.ln == 10):
|
elif (self.ln == 10):
|
||||||
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
|
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
|
||||||
|
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
|
|
||||||
|
|
||||||
def load_package(self):
|
def load_package(self):
|
||||||
@ -56,12 +66,21 @@ class Wozek():
|
|||||||
if dist <= 50:
|
if dist <= 50:
|
||||||
self.add_element(package)
|
self.add_element(package)
|
||||||
listOfPackages.list.pop()
|
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):
|
def drop_package(self):
|
||||||
package = self.remove_element()
|
package = self.remove_element()
|
||||||
if package is not None:
|
if package is not None:
|
||||||
listOfPackages.list.append(package)
|
package.x = self.obecnyStan.x
|
||||||
package.x = self.obecnyStan.x+50
|
|
||||||
package.y = self.obecnyStan.y
|
package.y = self.obecnyStan.y
|
||||||
|
listOfPackages.list.append(package)
|
||||||
|
|
||||||
def __zainicjuj_stan_poczatkowy(self):
|
def __zainicjuj_stan_poczatkowy(self):
|
||||||
from wyszukiwanie import Stan
|
from wyszukiwanie import Stan
|
||||||
|
Loading…
Reference in New Issue
Block a user