fixes_for_picking_up_and_screen_size #16

Merged
s472778 merged 4 commits from fixes_for_picking_up_and_screen_size into master 2023-05-28 00:08:41 +02:00
4 changed files with 22 additions and 8 deletions
Showing only changes of commit 4db472de98 - Show all commits

View File

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

View File

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

View File

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

View File

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