2023-03-21 12:36:50 +01:00
|
|
|
import pygame
|
2023-04-20 20:54:58 +02:00
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
MAX_STORAGE = 3
|
2023-03-21 12:36:50 +01:00
|
|
|
|
|
|
|
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
|
|
|
i = 1
|
2023-05-06 13:53:01 +02:00
|
|
|
pixele = 73
|
2023-03-21 12:36:50 +01:00
|
|
|
while (i < wymiar):
|
2023-05-06 13:53:01 +02:00
|
|
|
pixele = pixele + 70
|
2023-03-21 12:36:50 +01:00
|
|
|
i = i + 1
|
|
|
|
return pixele
|
|
|
|
|
|
|
|
def obliczPixeleDlugosciRegalu(self): #Przeliczanie dlugości regału podanego w kratkach na pixele
|
|
|
|
i = 1
|
|
|
|
dlugoscRegalu = 40
|
2023-05-29 00:13:02 +02:00
|
|
|
while (i < 1) and (i <= 11 - self.numerKolumny): #Sprawdzenie, żeby regał nie wychodził poza plansze, jeżeli tak to jest ucinany tak, żeby nie wychodził
|
2023-03-21 12:36:50 +01:00
|
|
|
dlugoscRegalu = dlugoscRegalu + 80
|
|
|
|
i = i + 1
|
|
|
|
return dlugoscRegalu
|
|
|
|
|
2023-05-28 00:02:24 +02:00
|
|
|
class Regal(pygame.sprite.Sprite):
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
def __init__(self, nazwaRegalu, numerWiersza, numerKolumny):
|
2023-05-28 00:02:24 +02:00
|
|
|
super().__init__()
|
2023-05-06 15:20:40 +02:00
|
|
|
from ekran import screen
|
2023-05-29 00:13:02 +02:00
|
|
|
self.nazwaRegalu = nazwaRegalu
|
2023-03-26 21:21:52 +02:00
|
|
|
self.wysokoscRegalu = 64
|
2023-03-21 12:36:50 +01:00
|
|
|
self.numerKolumny = numerKolumny
|
2023-05-29 00:13:02 +02:00
|
|
|
self.numerWiersza = numerWiersza
|
2023-03-21 12:36:50 +01:00
|
|
|
|
|
|
|
self.wiersz = obliczPixeleNaPodstawieKratek(numerWiersza)
|
|
|
|
self.kolumna = obliczPixeleNaPodstawieKratek(numerKolumny)
|
|
|
|
self.dlugosc = obliczPixeleDlugosciRegalu(self)
|
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
storage_dolna = []
|
|
|
|
storage_gorna = []
|
|
|
|
|
|
|
|
self.dolna = storage_dolna
|
|
|
|
self.gorna = storage_gorna
|
2023-04-20 20:54:58 +02:00
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
if(self.nazwaRegalu == 'ogród'):
|
2023-03-26 21:21:52 +02:00
|
|
|
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
|
|
|
reg = pygame.image.load("images/regal.png")
|
2023-05-28 00:02:24 +02:00
|
|
|
self.rect = reg.get_rect()
|
2023-03-26 21:21:52 +02:00
|
|
|
screen.blit(reg, (self.wiersz, self.kolumna))
|
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
if(self.nazwaRegalu == 'narzedzia'):
|
2023-03-26 21:21:52 +02:00
|
|
|
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
|
|
|
reg = pygame.image.load("images/regal1.png")
|
2023-05-28 00:02:24 +02:00
|
|
|
self.rect = reg.get_rect()
|
2023-03-26 21:21:52 +02:00
|
|
|
screen.blit(reg, (self.wiersz, self.kolumna))
|
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
if(self.nazwaRegalu == 'kuchnia'):
|
2023-03-26 21:21:52 +02:00
|
|
|
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
|
|
|
reg = pygame.image.load("images/regal2.png")
|
2023-05-28 00:02:24 +02:00
|
|
|
self.rect = reg.get_rect()
|
2023-03-26 21:21:52 +02:00
|
|
|
screen.blit(reg, (self.wiersz, self.kolumna))
|
|
|
|
|
2023-05-29 00:13:02 +02:00
|
|
|
if(self.nazwaRegalu == 'motoryzacja'):
|
2023-03-26 21:21:52 +02:00
|
|
|
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
|
|
|
reg = pygame.image.load("images/regal3.png")
|
2023-05-28 00:02:24 +02:00
|
|
|
self.rect = reg.get_rect()
|
2023-03-26 21:21:52 +02:00
|
|
|
screen.blit(reg, (self.wiersz, self.kolumna))
|
2023-05-29 00:13:02 +02:00
|
|
|
|
|
|
|
def is_dolna_free(self):
|
|
|
|
if len(self.dolna) <= MAX_STORAGE:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def is_gorna_free(self):
|
|
|
|
if len(self.gorna) <= MAX_STORAGE:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def czy_na_gornej_wiecej_miejsca(self):
|
|
|
|
if len(self.gorna) > len(self.dolna):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2023-05-29 00:48:58 +02:00
|
|
|
def put_package_on_the_regal(self, package, where):
|
|
|
|
if(where == 0):
|
|
|
|
self.dolna.append(package)
|
|
|
|
else:
|
2023-06-18 13:07:05 +02:00
|
|
|
self.gorna.append(package)
|