2023-03-26 18:13:07 +02:00
|
|
|
from etykieta import Etykieta
|
2023-04-20 20:54:58 +02:00
|
|
|
import pygame
|
2023-03-24 13:46:38 +01:00
|
|
|
|
|
|
|
|
2023-05-27 23:23:02 +02:00
|
|
|
class Paczka(pygame.sprite.Sprite):
|
2023-03-24 13:46:38 +01:00
|
|
|
|
2023-05-25 19:59:54 +02:00
|
|
|
def __init__(self, rozmiar, waga, kategoria, priorytet, ksztalt, kruchosc, nadawca, adres, imie, nazwisko, telefon):
|
2023-05-27 23:23:02 +02:00
|
|
|
super().__init__()
|
2023-03-24 13:46:38 +01:00
|
|
|
self.rozmiar = rozmiar
|
2023-05-06 14:54:04 +02:00
|
|
|
self.image = pygame.image.load("images/paczka.png")
|
2023-05-27 23:23:02 +02:00
|
|
|
self.rect = self.image.get_rect()
|
2023-05-06 14:54:04 +02:00
|
|
|
if rozmiar == 'duzy':
|
|
|
|
self.image = pygame.transform.scale(self.image, (50, 50))
|
|
|
|
self.szerokosc = 50
|
|
|
|
self.wysokosc = 50
|
|
|
|
elif rozmiar == 'sredni':
|
|
|
|
self.image = pygame.transform.scale(self.image, (35, 35))
|
|
|
|
self.szerokosc = 35
|
|
|
|
self.wysokosc = 35
|
|
|
|
elif rozmiar == 'maly':
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
else:
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
self.rozmiar = 'undefined'
|
2023-03-24 13:46:38 +01:00
|
|
|
self.waga = waga
|
|
|
|
self.kategoria = kategoria
|
2023-05-25 19:59:54 +02:00
|
|
|
self.priorytet = priorytet
|
|
|
|
self.ksztalt = ksztalt
|
|
|
|
self.kruchosc = kruchosc
|
2023-05-06 14:54:04 +02:00
|
|
|
self.x = 430
|
|
|
|
self.y = 400
|
2023-05-25 19:59:54 +02:00
|
|
|
self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon, priorytet)
|
2023-03-24 13:46:38 +01:00
|
|
|
|
|
|
|
# zmienia rozmiar obrazka w zaleznosci od rozmiaru
|
|
|
|
def __dobierz_rozmiar_obrazka(self):
|
|
|
|
if self.rozmiar == "duzy":
|
|
|
|
self.image = pygame.transform.scale(self.image, (50, 50))
|
|
|
|
self.szerokosc = 50
|
|
|
|
self.wysokosc = 50
|
|
|
|
return 1
|
|
|
|
elif self.rozmiar == "sredni":
|
|
|
|
self.image = pygame.transform.scale(self.image, (35, 35))
|
|
|
|
self.szerokosc = 35
|
|
|
|
self.wysokosc = 35
|
|
|
|
return 1
|
|
|
|
elif self.rozmiar == "maly":
|
|
|
|
self.image = pygame.transform.scale(self.image, (20, 20))
|
|
|
|
self.szerokosc = 20
|
|
|
|
self.wysokosc = 20
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def narysuj(self, x, y, screen):
|
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
if self.__dobierz_rozmiar_obrazka() == 1:
|
|
|
|
screen.blit(self.image, (self.x, self.y))
|
|
|
|
else:
|
|
|
|
print("Zmien rozmiar paczki")
|
|
|
|
print("Paczka moze miec rozmiar duzy, sredni lub maly")
|
|
|
|
exit(0)
|
2023-05-27 23:23:02 +02:00
|
|
|
|
|
|
|
def update_position(self, x, y):
|
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
self.rect.topleft = (x, y)
|