From 01e3724d8ef1d209aa596087ec8deaba308c2ce5 Mon Sep 17 00:00:00 2001 From: s473561 Date: Mon, 29 May 2023 11:00:58 +0200 Subject: [PATCH] =?UTF-8?q?na=20rampie=20mo=C5=BCe=20le=C5=BCe=C4=87=20kil?= =?UTF-8?q?ka=20paczek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/ekran.cpython-311.pyc | Bin 5622 -> 5941 bytes __pycache__/paczka.cpython-311.pyc | Bin 6117 -> 6146 bytes __pycache__/wozek.cpython-311.pyc | Bin 6903 -> 6825 bytes ekran.py | 18 +++++++++++---- main.py | 34 +++++++++++++++++++---------- paczka.py | 1 + wozek.py | 20 ++++++++++++----- 7 files changed, 51 insertions(+), 22 deletions(-) diff --git a/__pycache__/ekran.cpython-311.pyc b/__pycache__/ekran.cpython-311.pyc index 47151c8f20826d2d4f8eb1985a91c2d1beee9488..70bdb4e03d99309b7c37170c494b70c7768c225c 100644 GIT binary patch delta 1098 zcmZWoO-~a+7@pa7>t@?-X=||}R3h@RVh9v01{%PK_<jjxoZdAw-IBl)NcL?wxL-UDz7{Zt*C{6| zd>2gZ+(?OW?C1eXdg!K8$NhA~)x@8Gfhf(np5qkV=l;U!e(I9y>;+U5>40=NsMkWl zPRqC~R&+zM+kFyZ!a$Ztl-`h<`q*-YlvBu(me0hlDe>#GX(RYotj2OmjHpQ^tCBXh zKp%tS^t}`j&jURLuXdAS&!||xX%Cg{p^`mB&w1YN?`DNQ0GT7l81H4=Mh0o9Cc22dL!tfMb^XfxafjvYzpw))aOxrRp z;3Bq0cJ~FG;j9?Ajc(ZvtzdLVPM`@y+94(LhAW%abj6fGoi+CC$Up`mONJOkSsh14 zp)(w&T8hS&ZEPg1EPvX9D?l_R)GGQeApgM%!hE+0w;Wr7bXU49-CJ0Buvn~p5_}oi z6vAa8Tr!`E&8j3a%#XucZ4O{Ic)u+I{CE1UWmG_!>gf|Wk4Os`qk8V@IzXV(wqgxH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aQD#Z%Ew*4V4Yp||Ly<1XLXg$JIBatBQ%ZAE?TUOSw~Cv) cl`=BQe_+5)c7*lBUg1^z2$ueWLlM|)01}CAhyVZp diff --git a/__pycache__/wozek.cpython-311.pyc b/__pycache__/wozek.cpython-311.pyc index 406dafd25f29794a209f22189270ebe09a229eaa..bd1ce4491e21b3918df5e778be8259d5ae366662 100644 GIT binary patch delta 626 zcmexvy3&+yIWI340}xb(l%!+}ZRE4!ot)3Y$@v8+G@YS@fnjn1qweHF-hM{$$&7qj zo+%8$3?Qt@?DvuhsOF^+kkI6~#g~&=T;iV=keHmEn4Vf(qz@Fn#gdy?l5vZrxUi_C zh#M$SBo87KK!on(EquQ96+mVK!&d3GA~M*?@+ubX}zOlPyH49fD6G;Wzn$#1UO?R<#cd za6*QWmG=V!oDg7R)&9T$Cj=%Rl#FGxnJh1*Eae0;LJ~xPto+4clbfGXnv-f*lr%X; g$~&N#kz~n3Xj4^h>|aORDx{*07b#4?EnA( delta 720 zcmZ2!`rVXoIWI340}wpAS)6i9U?ZOuFCQC_%M8SyB^VhPrcaI+6K8Q@h^?92&fCvw zT*I({eX^pM@MJwc;mHYN;*&#!MJEdg@aZx#^wg#>1T$zd`@LiW>V9biBs4j1@#SO| zm-wdzBqnDkrl%I)Vgd0d=kh5q73ojz;`6QV0;+3ZxGS!DMO^Cx0}CgF=y1O)EI!3@ zM#`N0D{}f9)VF9}l(XKEcv05=fXNa2E6yPo!sD)lCtP$+xR9K3(JAGkY|2I9)GNZN z9WFQcg(nnsRdrO|5D>X8pm0e*VS)HX0nIA{nim8#?+VCW5m3G^pngd}9W2NX68-Uk z6K3(`VEz(DkI5(awK#VGT{fKo=wq;l>zM@DY8h)78=WVs2n6tCu>xhmU;!I6K&07= zq=6!u?2}guND0{hnMIl)K2wnxh;2Xll7Jyw0FYT6HknhpW_gc+?h@ zU*yrh!lQoyhCZ-QjudPY@&M`NMl!`?@<%~`#_-LKLaI!R(VNpnCNo)uffR*+3>y;LlB$mgQgV^!q@!6TFMWuP!rKy`u#7!8b96_pGK!h8J z5Csw8Ai{rglf)5SR#sq~zzIG^R^AT`a6*8U)c_<5CHN*6OU5$VPQECqEaeO`LJ~xP wob!vrCO1E&G$+-rD0woUly^WjBcm(h2L{|!hg*;D6&{6;5G7yms07;r02q72o&W#< diff --git a/ekran.py b/ekran.py index c009c34..a75ffa4 100644 --- a/ekran.py +++ b/ekran.py @@ -16,8 +16,10 @@ icon = pygame.image.load('images/icon.png') pygame.display.set_icon(icon) # lista_paczek = packageList.zainicjuj_liste_paczek(a_pix, b_pix) -lista_paczek = listOfPackages() +#lista_paczek = listOfPackages() +lista_paczek = [] +lista_paczek_na_regalach = [] def narysuj_regaly(): global lista_regalow @@ -69,6 +71,7 @@ def odswiez_ekran(wozek): screen.blit(miejsce,(a_pix, b_pix)) narysuj_siatke() narysuj_paczki(wozek) + narysuj_paczke_na_regale() narysuj_regaly() wozek.draw() pygame.display.flip() @@ -91,6 +94,13 @@ def sprawdz_ktora_kolumna(y): def narysuj_paczki(wozek): - if wozek.ln == 0: - for paczka in lista_paczek.list: - paczka.narysuj(paczka.x, paczka.y, screen) + #if wozek.ln == 0: + #for paczka in lista_paczek.list: + #if len(lista_paczek_na_regalach) == 0: + for paczka in lista_paczek: + paczka.narysuj(paczka.x, paczka.y, screen) + +def narysuj_paczke_na_regale(): + for paczka in lista_paczek_na_regalach: + if paczka.is_in_move is False: + paczka.narysuj(paczka.x, paczka.y, screen) \ No newline at end of file diff --git a/main.py b/main.py index 32bf3db..b08e673 100644 --- a/main.py +++ b/main.py @@ -8,17 +8,19 @@ from grid import GridCellType, SearchGrid from sklearn.tree import DecisionTreeClassifier import pandas as pd -from plansza import x1, y1, x2, y2, x3, y3, x4, y4, a_pix, b_pix +from plansza import a_pix, b_pix pygame.init() def main(): wozek = Wozek() - #paczka = Paczka('duzy', 12, 'narzedzia', False, True, False, any, any, any, any, any) - paczka = Paczka('maly', 1, 'ogród', False, True, False, any, any, any, any, any) - ekran.lista_paczek.add(paczka) - paczka.update_position(a_pix, b_pix) + p1 = Paczka('duzy', 12, 'narzedzia', False, True, False, any, any, any, any, any) + p2 = Paczka('maly', 1, 'ogród', False, True, False, any, any, any, any, any) + ekran.lista_paczek.append(p1) + ekran.lista_paczek.append(p2) + p1.update_position(a_pix, b_pix) + p2.update_position(a_pix, b_pix) grid_points = SearchGrid() @@ -42,11 +44,16 @@ def main(): if grid_points.grid[(wiersz, kolumna)] is GridCellType.PLACE: #picks up package if wozek.ln == 0: - wozek.load_package() - wozek.dynamic_wozek_picture + paczka_pop = ekran.lista_paczek.pop() + ekran.lista_paczek_na_regalach.append(paczka_pop) + paczka_pop.is_in_move = True + wozek.storage.append(paczka_pop) + wozek.ln = wozek.ln + 1 + wozek.dynamic_wozek_picture() + print(ekran.lista_paczek) ## wozek jedzie odlozyc paczke na regal - paczka1 = wozek.storage[0] + paczka1 = wozek.storage[-1] array, reg = paczka1.tablica_do_drzewa(paczka1.kategoria) @@ -82,14 +89,17 @@ def main(): sciezka = wyszukiwanie.znajdz_sciezke(wezel) wozek.przemiesc_wozek_po_sciezce(sciezka) - # print(wozek.storage) if wozek.ln != 0: # drops package - wozek.drop_package() + print(paczka1) + paczka1.update_position(reg.numerWiersza*70, reg.numerKolumny*70) + paczka_pop.is_in_move = False + wozek.storage.pop() + wozek.ln = wozek.ln - 1 reg.put_package_on_the_regal(paczka1, predictions) wozek.dynamic_wozek_picture() + ekran.odswiez_ekran(wozek) - - if event.type == pygame.MOUSEBUTTONDOWN: + if event.type == pygame.MOUSEBUTTONDOWN: # lewy przycisk myszy if event.button == 1: x = pygame.mouse.get_pos()[0] diff --git a/paczka.py b/paczka.py index f59a55b..71ea4a6 100644 --- a/paczka.py +++ b/paczka.py @@ -34,6 +34,7 @@ class Paczka(pygame.sprite.Sprite): self.x = 430 self.y = 400 self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon, priorytet) + self.is_in_move = False # zmienia rozmiar obrazka w zaleznosci od rozmiaru def __dobierz_rozmiar_obrazka(self): diff --git a/wozek.py b/wozek.py index 867e5d1..27f4dca 100644 --- a/wozek.py +++ b/wozek.py @@ -63,11 +63,18 @@ class Wozek(pygame.sprite.Sprite): def load_package(self): - for package in listOfPackages.list: - dist = math.sqrt((self.obecnyStan.x - package.x)**2 + (self.obecnyStan.y - package.y)**2) - if dist <= 50: - self.add_element(package) - listOfPackages.list.pop() + #for package in listOfPackages.list: + # for package in listOfPackages: + # dist = math.sqrt((self.obecnyStan.x - package.x)**2 + (self.obecnyStan.y - package.y)**2) + # if dist <= 50: + # self.add_element(package) + # # listOfPackages.list.pop() + # listOfPackages.pop() + package = listOfPackages.pop() + dist = math.sqrt((self.obecnyStan.x - package.x)**2 + (self.obecnyStan.y - package.y)**2) + if dist <= 50: + self.add_element(package) + # listOfPackages.list.pop() def load_packages_collision(self): pass @@ -82,7 +89,8 @@ class Wozek(pygame.sprite.Sprite): if package is not None: package.x = self.obecnyStan.x package.y = self.obecnyStan.y - listOfPackages.list.append(package) + # listOfPackages.list.append(package) + listOfPackages.append(package) def __zainicjuj_stan_poczatkowy(self): from wyszukiwanie import Stan