forked from s474139/Inteligentny_Wozek
paczka can be picked up and placed anywhere by wozek
This commit is contained in:
parent
82d1b7088e
commit
4db472de98
4
ekran.py
4
ekran.py
@ -16,7 +16,7 @@ pygame.display.set_caption("Inteligentny wozek")
|
||||
icon = pygame.image.load('images/icon.png')
|
||||
pygame.display.set_icon(icon)
|
||||
|
||||
lista_paczek = packageList.zainicjuj_liste_paczek()
|
||||
lista_paczek = packageList.zainicjuj_liste_paczek(a_pix, b_pix)
|
||||
|
||||
def narysuj_regaly():
|
||||
regal.Regal(1, 1, x1, y1)
|
||||
@ -78,4 +78,4 @@ def sprawdz_ktora_kolumna(y):
|
||||
def narysuj_paczki(wozek):
|
||||
if wozek.ln == 0:
|
||||
for paczka in lista_paczek.list:
|
||||
paczka.narysuj(a_pix, b_pix, screen)
|
||||
paczka.narysuj(paczka.x, paczka.y, screen)
|
||||
|
4
main.py
4
main.py
@ -64,8 +64,8 @@ def main():
|
||||
wozek.obecnyStan.x = 916
|
||||
if wozek.obecnyStan.y <= 0:
|
||||
wozek.obecnyStan.y = 0
|
||||
elif wozek.obecnyStan.x >= 916:
|
||||
wozek.obecnyStan.x = 916
|
||||
elif wozek.obecnyStan.y >= 916:
|
||||
wozek.obecnyStan.y = 916
|
||||
|
||||
ekran.odswiez_ekran(wozek)
|
||||
|
||||
|
@ -1,16 +1,23 @@
|
||||
import pygame
|
||||
|
||||
from paczka import Paczka
|
||||
|
||||
class listOfPackages:
|
||||
list = []
|
||||
package_group = pygame.sprite.Group()
|
||||
|
||||
def add(self, item):
|
||||
self.list.append(item)
|
||||
self.package_group.add(item)
|
||||
|
||||
def remove(self):
|
||||
self.list.pop()
|
||||
last_package = self.list.pop()
|
||||
self.package_group.remove(last_package)
|
||||
|
||||
|
||||
def zainicjuj_liste_paczek():
|
||||
from paczka import Paczka
|
||||
def zainicjuj_liste_paczek(init_x, init_y):
|
||||
packageList = listOfPackages()
|
||||
demo_paczka = Paczka('duzy', 10, any, False, True, False, any, any, any, any, any)
|
||||
demo_paczka.update_position(init_x, init_y)
|
||||
packageList.add(demo_paczka)
|
||||
return packageList
|
||||
|
@ -2,11 +2,13 @@ from etykieta import Etykieta
|
||||
import pygame
|
||||
|
||||
|
||||
class Paczka:
|
||||
class Paczka(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self, rozmiar, waga, kategoria, priorytet, ksztalt, kruchosc, nadawca, adres, imie, nazwisko, telefon):
|
||||
super().__init__()
|
||||
self.rozmiar = rozmiar
|
||||
self.image = pygame.image.load("images/paczka.png")
|
||||
self.rect = self.image.get_rect()
|
||||
if rozmiar == 'duzy':
|
||||
self.image = pygame.transform.scale(self.image, (50, 50))
|
||||
self.szerokosc = 50
|
||||
@ -62,3 +64,8 @@ class Paczka:
|
||||
print("Zmien rozmiar paczki")
|
||||
print("Paczka moze miec rozmiar duzy, sredni lub maly")
|
||||
exit(0)
|
||||
|
||||
def update_position(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.rect.topleft = (x, y)
|
Loading…
Reference in New Issue
Block a user