2023-05-06 13:40:17 +02:00
|
|
|
import pygame
|
2023-05-08 11:27:16 +02:00
|
|
|
from plansza import x1, y1, x2, y2, x3, y3, x4, y4, a_pix, b_pix
|
2023-05-29 00:13:02 +02:00
|
|
|
from regal import Regal, obliczPixeleNaPodstawieKratek
|
2023-05-06 14:54:04 +02:00
|
|
|
from packageList import *
|
2023-05-06 13:40:17 +02:00
|
|
|
|
2023-05-27 23:50:48 +02:00
|
|
|
EKRAN_SZEROKOSC = 770
|
|
|
|
EKRAN_WYSOKOSC = 770
|
2023-05-06 13:40:17 +02:00
|
|
|
screen = pygame.display.set_mode((EKRAN_SZEROKOSC, EKRAN_WYSOKOSC))
|
|
|
|
miejsce = pygame.image.load('images/miejsce_paczek.png')
|
2023-05-06 18:06:30 +02:00
|
|
|
miejsce = pygame.transform.scale(miejsce, (140, 140))
|
2023-05-06 13:40:17 +02:00
|
|
|
pygame.display.set_caption("Inteligentny wozek")
|
|
|
|
icon = pygame.image.load('images/icon.png')
|
|
|
|
pygame.display.set_icon(icon)
|
|
|
|
|
2023-05-29 11:00:58 +02:00
|
|
|
lista_paczek = []
|
|
|
|
lista_paczek_na_regalach = []
|
2023-05-29 00:13:02 +02:00
|
|
|
|
2023-05-06 13:40:17 +02:00
|
|
|
def narysuj_regaly():
|
2023-05-29 00:13:02 +02:00
|
|
|
global lista_regalow
|
|
|
|
r1 = Regal('ogród', x1, y1)
|
|
|
|
r2 = Regal('ogród', x1, y1+1)
|
|
|
|
r3 = Regal('ogród', x1+1, y1)
|
|
|
|
r4 = Regal('ogród', x1+1, y1+1)
|
|
|
|
|
|
|
|
r5 = Regal('narzedzia', x2, y2)
|
|
|
|
r6 = Regal('narzedzia', x2, y2+1)
|
|
|
|
r7 = Regal('narzedzia', x2+1, y2)
|
|
|
|
r8 = Regal('narzedzia', x2+1, y2+1)
|
|
|
|
|
|
|
|
r9 = Regal('kuchnia', x3, y3)
|
|
|
|
r10 = Regal('kuchnia', x3, y3+1)
|
|
|
|
r11 = Regal('kuchnia', x3+1, y3)
|
|
|
|
r12 = Regal('kuchnia', x3+1, y3+1)
|
|
|
|
|
|
|
|
r13 = Regal('motoryzacja', x4, y4)
|
|
|
|
r14 = Regal('motoryzacja', x4, y4+1)
|
|
|
|
r15 = Regal('motoryzacja', x4+1, y4)
|
|
|
|
r16 = Regal('motoryzacja', x4+1, y4+1)
|
|
|
|
|
|
|
|
lista_regalow = [r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16]
|
|
|
|
|
|
|
|
def zwroc_regaly_kategoria(kategoria):
|
|
|
|
lista_reg = []
|
|
|
|
for reg in lista_regalow:
|
|
|
|
if reg.nazwaRegalu == kategoria:
|
|
|
|
lista_reg.append(reg)
|
|
|
|
return lista_reg
|
|
|
|
|
2023-05-06 13:53:01 +02:00
|
|
|
def narysuj_siatke():
|
|
|
|
blockSize = 70 # Set the size of the grid block
|
2023-05-06 13:40:17 +02:00
|
|
|
WHITE = (200, 200, 200)
|
|
|
|
for x in range(0, EKRAN_SZEROKOSC, blockSize):
|
|
|
|
for y in range(0, EKRAN_WYSOKOSC, blockSize):
|
|
|
|
rect = pygame.Rect(x, y, blockSize, blockSize)
|
|
|
|
pygame.draw.rect(screen, WHITE, rect, 1)
|
2023-05-06 13:53:01 +02:00
|
|
|
|
|
|
|
|
2023-05-06 13:40:17 +02:00
|
|
|
def odswiez_ekran(wozek):
|
2023-05-08 11:27:16 +02:00
|
|
|
screen.fill((51, 51, 51)) # removes object trail
|
|
|
|
screen.blit(miejsce,(a_pix, b_pix))
|
2023-05-06 13:53:01 +02:00
|
|
|
narysuj_siatke()
|
2023-05-06 14:54:04 +02:00
|
|
|
narysuj_paczki(wozek)
|
2023-05-29 11:00:58 +02:00
|
|
|
narysuj_paczke_na_regale()
|
2023-05-06 13:40:17 +02:00
|
|
|
narysuj_regaly()
|
|
|
|
wozek.draw()
|
|
|
|
pygame.display.flip()
|
|
|
|
|
|
|
|
|
|
|
|
def sprawdz_ktory_wiersz(x):
|
|
|
|
nr_wiersza = 0
|
|
|
|
for i in range(70, EKRAN_WYSOKOSC + 70, 70):
|
|
|
|
if x < i:
|
|
|
|
return nr_wiersza
|
|
|
|
nr_wiersza = nr_wiersza + 1
|
2023-05-06 13:53:01 +02:00
|
|
|
|
|
|
|
|
2023-05-06 13:40:17 +02:00
|
|
|
def sprawdz_ktora_kolumna(y):
|
|
|
|
nr_kolumny = 0
|
|
|
|
for i in range(70, EKRAN_SZEROKOSC + 70, 70):
|
|
|
|
if y < i:
|
|
|
|
return nr_kolumny
|
2023-05-06 13:53:01 +02:00
|
|
|
nr_kolumny = nr_kolumny + 1
|
2023-05-06 14:54:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
def narysuj_paczki(wozek):
|
2023-05-29 11:00:58 +02:00
|
|
|
for paczka in lista_paczek:
|
|
|
|
paczka.narysuj(paczka.x, paczka.y, screen)
|
|
|
|
|
|
|
|
def narysuj_paczke_na_regale():
|
|
|
|
for paczka in lista_paczek_na_regalach:
|
|
|
|
if paczka.is_in_move is False:
|
2023-05-30 18:47:23 +02:00
|
|
|
paczka.narysuj(paczka.x, paczka.y, screen)
|
|
|
|
|
|
|
|
def dodaj_paczki_na_rampe(p1, p2):
|
|
|
|
lista_paczek.append(p1)
|
|
|
|
lista_paczek.append(p2)
|
|
|
|
p1.update_position(a_pix, b_pix)
|
|
|
|
p2.update_position(a_pix, b_pix)
|