fixes_for_picking_up_and_screen_size #16
8
ekran.py
8
ekran.py
@ -7,8 +7,8 @@ import wozek
|
||||
from packageList import *
|
||||
from paczka import Paczka
|
||||
|
||||
EKRAN_SZEROKOSC = 980
|
||||
EKRAN_WYSOKOSC = 980
|
||||
EKRAN_SZEROKOSC = 770
|
||||
EKRAN_WYSOKOSC = 770
|
||||
screen = pygame.display.set_mode((EKRAN_SZEROKOSC, EKRAN_WYSOKOSC))
|
||||
miejsce = pygame.image.load('images/miejsce_paczek.png')
|
||||
miejsce = pygame.transform.scale(miejsce, (140, 140))
|
||||
@ -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)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 3.8 KiB |
8
main.py
8
main.py
@ -60,12 +60,12 @@ def main():
|
||||
|
||||
if wozek.obecnyStan.x <= 0:
|
||||
wozek.obecnyStan.x = 0
|
||||
elif wozek.obecnyStan.x >= 916:
|
||||
wozek.obecnyStan.x = 916
|
||||
elif wozek.obecnyStan.x >= ekran.EKRAN_SZEROKOSC-70:
|
||||
wozek.obecnyStan.x = ekran.EKRAN_SZEROKOSC-70
|
||||
if wozek.obecnyStan.y <= 0:
|
||||
wozek.obecnyStan.y = 0
|
||||
elif wozek.obecnyStan.x >= 916:
|
||||
wozek.obecnyStan.x = 916
|
||||
elif wozek.obecnyStan.y >= ekran.EKRAN_WYSOKOSC-70:
|
||||
wozek.obecnyStan.y = ekran.EKRAN_WYSOKOSC-70
|
||||
|
||||
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)
|
@ -8,8 +8,8 @@ def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podany
|
||||
i = i + 1
|
||||
return pixele
|
||||
|
||||
EKRAN_SZEROKOSC = 980
|
||||
EKRAN_WYSOKOSC = 980
|
||||
EKRAN_SZEROKOSC = 770
|
||||
EKRAN_WYSOKOSC = 770
|
||||
blockSize = 70
|
||||
|
||||
x1, y1, x2, y2, x3, y3, x4, y4 = [None] * 8
|
||||
|
14
regal.py
14
regal.py
@ -18,8 +18,9 @@ def obliczPixeleDlugosciRegalu(self): #Przeliczanie dlugości regału podanego
|
||||
i = i + 1
|
||||
return dlugoscRegalu
|
||||
|
||||
class Regal:
|
||||
class Regal(pygame.sprite.Sprite):
|
||||
def __init__(self, numerRegalu, dlugoscRegaluWKratkach, numerWiersza, numerKolumny):
|
||||
super().__init__()
|
||||
from ekran import screen
|
||||
self.numerRegalu = numerRegalu
|
||||
self.wysokoscRegalu = 64
|
||||
@ -30,26 +31,33 @@ class Regal:
|
||||
self.kolumna = obliczPixeleNaPodstawieKratek(numerKolumny)
|
||||
self.dlugosc = obliczPixeleDlugosciRegalu(self)
|
||||
|
||||
# from main import screen
|
||||
# from ekran import screen
|
||||
package_storage = []
|
||||
shelfs = { # here packages are stored
|
||||
"dolna": package_storage,
|
||||
"gorna": package_storage
|
||||
}
|
||||
|
||||
if(self.numerRegalu >= 0 and self.numerRegalu <= 4):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 5 and self.numerRegalu <= 8):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal1.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 9 and self.numerRegalu <= 12):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal2.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 13 and self.numerRegalu <= 16):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal3.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
|
25
wozek.py
25
wozek.py
@ -3,8 +3,9 @@ import pygame,math
|
||||
from packageList import listOfPackages
|
||||
|
||||
|
||||
class Wozek():
|
||||
class Wozek(pygame.sprite.Sprite):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.obecnyStan = None
|
||||
# self.x = 55
|
||||
# self.y = 55
|
||||
@ -13,12 +14,14 @@ class Wozek():
|
||||
self.height = 64
|
||||
self.width = 64
|
||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||
self.rect = self.image.get_rect()
|
||||
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||
# https://www.flaticon.com/free-icons/forklift
|
||||
self.__zainicjuj_stan_poczatkowy()
|
||||
|
||||
def draw(self):
|
||||
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
||||
# self.update_position(self.obecnyStan.x, self.obecnyStan.y)
|
||||
|
||||
#storage = ["none"] * 10
|
||||
storage = []
|
||||
@ -39,6 +42,11 @@ class Wozek():
|
||||
else:
|
||||
print("I'm empty!")
|
||||
|
||||
def update_position(self, x, y):
|
||||
self.obecnyStan.x = x
|
||||
self.obecnyStan.y = y
|
||||
self.rect.topleft = (x, y)
|
||||
|
||||
def dynamic_wozek_picture(self):
|
||||
if self.ln == 0:
|
||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||
@ -49,6 +57,8 @@ class Wozek():
|
||||
elif (self.ln == 10):
|
||||
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
|
||||
|
||||
self.rect = self.image.get_rect()
|
||||
|
||||
|
||||
def load_package(self):
|
||||
for package in listOfPackages.list:
|
||||
@ -56,12 +66,21 @@ class Wozek():
|
||||
if dist <= 50:
|
||||
self.add_element(package)
|
||||
listOfPackages.list.pop()
|
||||
|
||||
def load_packages_collision(self):
|
||||
pass
|
||||
# packages_collision = pygame.sprite.spritecollide(self, listOfPackages.package_group, False)
|
||||
# if packages_collision:
|
||||
# for package in packages_collision:
|
||||
# self.add_element(package)
|
||||
# listOfPackages.list.remove(package) # collision doesn't work, collision always happens
|
||||
|
||||
def drop_package(self):
|
||||
package = self.remove_element()
|
||||
if package is not None:
|
||||
listOfPackages.list.append(package)
|
||||
package.x = self.obecnyStan.x+50
|
||||
package.x = self.obecnyStan.x
|
||||
package.y = self.obecnyStan.y
|
||||
listOfPackages.list.append(package)
|
||||
|
||||
def __zainicjuj_stan_poczatkowy(self):
|
||||
from wyszukiwanie import Stan
|
||||
|
Loading…
Reference in New Issue
Block a user