2023-05-06 13:53:01 +02:00
|
|
|
import ekran
|
2023-06-18 13:07:05 +02:00
|
|
|
import pygame
|
2023-06-02 21:14:55 +02:00
|
|
|
from ekran import lista_itemow
|
|
|
|
from letter import Letter
|
|
|
|
import plansza
|
2023-03-27 12:10:08 +02:00
|
|
|
|
2023-06-02 21:14:55 +02:00
|
|
|
listOfPackages = lista_itemow
|
2023-03-27 12:10:08 +02:00
|
|
|
|
2023-05-27 23:20:08 +02:00
|
|
|
class Wozek(pygame.sprite.Sprite):
|
2023-03-27 12:10:08 +02:00
|
|
|
def __init__(self):
|
2023-05-27 23:20:08 +02:00
|
|
|
super().__init__()
|
2023-05-06 13:53:01 +02:00
|
|
|
self.obecnyStan = None
|
2023-03-27 12:10:08 +02:00
|
|
|
self.height = 64
|
|
|
|
self.width = 64
|
|
|
|
# Credit: Forklift icons created by Smashicons - Flaticon
|
|
|
|
# https://www.flaticon.com/free-icons/forklift
|
2023-06-18 13:07:05 +02:00
|
|
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
|
|
|
self.rect = self.image.get_rect()
|
2023-04-20 20:54:58 +02:00
|
|
|
self.__zainicjuj_stan_poczatkowy()
|
2023-03-27 12:10:08 +02:00
|
|
|
|
|
|
|
def draw(self):
|
2023-05-06 13:53:01 +02:00
|
|
|
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
2023-03-27 12:10:08 +02:00
|
|
|
|
|
|
|
storage = []
|
|
|
|
max_size = 10
|
2023-05-06 14:54:04 +02:00
|
|
|
ln = len(storage)
|
2023-03-27 12:10:08 +02:00
|
|
|
|
2023-05-06 14:54:04 +02:00
|
|
|
def dynamic_wozek_picture(self):
|
|
|
|
if self.ln == 0:
|
|
|
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
|
|
|
elif ((self.ln > 0) and (self.ln < 4)):
|
|
|
|
self.image = pygame.image.load("images/pelny_wozek_1_crate.png")
|
|
|
|
elif ((self.ln > 3) and (self.ln < 10)):
|
|
|
|
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")
|
2023-05-27 23:20:08 +02:00
|
|
|
|
2023-06-18 13:07:05 +02:00
|
|
|
self.rect = self.image.get_rect()
|
2023-04-20 20:54:58 +02:00
|
|
|
|
|
|
|
def __zainicjuj_stan_poczatkowy(self):
|
|
|
|
from wyszukiwanie import Stan
|
2023-05-30 21:00:08 +02:00
|
|
|
self.obecnyStan = Stan(0, 0, 1)
|
2023-04-20 20:54:58 +02:00
|
|
|
|
2023-05-06 13:53:01 +02:00
|
|
|
def przemiesc_wozek_po_sciezce(self, sciezka):
|
|
|
|
kierunek_poprzedni = self.obecnyStan.kierunek
|
|
|
|
for wezel in sciezka:
|
|
|
|
self.obecnyStan = wezel.stan
|
|
|
|
kierunek_obecny = self.obecnyStan.kierunek
|
|
|
|
self.ustaw_wozek_w_kierunku(kierunek_obecny, kierunek_poprzedni)
|
|
|
|
kierunek_poprzedni = kierunek_obecny
|
|
|
|
ekran.odswiez_ekran(self)
|
|
|
|
pygame.time.wait(500)
|
|
|
|
|
|
|
|
def ustaw_wozek_w_kierunku(self, kierunek_obecny, kierunek_poprzedni):
|
2023-05-06 14:54:04 +02:00
|
|
|
if kierunek_poprzedni < kierunek_obecny:
|
|
|
|
# obrot w lewo
|
|
|
|
if kierunek_poprzedni == 0 and kierunek_obecny == 3:
|
|
|
|
self.image = pygame.transform.rotate(self.image, 90)
|
|
|
|
# obrot w prawo
|
|
|
|
else:
|
|
|
|
self.image = pygame.transform.rotate(self.image, -90)
|
|
|
|
elif kierunek_poprzedni > kierunek_obecny:
|
|
|
|
# obrot w prawo
|
|
|
|
if kierunek_poprzedni == 3 and kierunek_obecny == 0:
|
|
|
|
self.image = pygame.transform.rotate(self.image, -90)
|
|
|
|
# obrot w lewo
|
|
|
|
else:
|
|
|
|
self.image = pygame.transform.rotate(self.image, 90)
|
2023-05-29 11:15:06 +02:00
|
|
|
|
2023-06-02 21:14:55 +02:00
|
|
|
def picks_up_item(self):
|
|
|
|
item_pop = ekran.lista_itemow.pop()
|
|
|
|
if isinstance(item_pop,Letter):
|
|
|
|
ekran.lista_listow_w_skrzynce.append(item_pop)
|
|
|
|
item_pop.is_in_move = True
|
|
|
|
self.storage.append(item_pop)
|
|
|
|
self.ln = self.ln + 1
|
|
|
|
else:
|
|
|
|
ekran.lista_paczek_na_regalach.append(item_pop)
|
|
|
|
item_pop.is_in_move = True
|
|
|
|
self.storage.append(item_pop)
|
|
|
|
self.ln = self.ln + 1
|
2023-05-29 11:15:06 +02:00
|
|
|
|
|
|
|
def drops_package(self, paczka, reg, predictions):
|
|
|
|
paczka.update_position(reg.numerWiersza*70, reg.numerKolumny*70)
|
|
|
|
paczka.is_in_move = False
|
|
|
|
self.storage.pop()
|
|
|
|
self.ln = self.ln - 1
|
|
|
|
reg.put_package_on_the_regal(paczka, predictions)
|
2023-04-20 20:54:58 +02:00
|
|
|
|
2023-06-02 21:14:55 +02:00
|
|
|
def drops_letter(self, letter):
|
|
|
|
letter.update_position(plansza.c_pix, plansza.d_pix)
|
|
|
|
letter.is_in_move = False
|
|
|
|
self.storage.pop()
|
|
|
|
self.ln = self.ln - 1
|
|
|
|
|