2023-05-06 13:40:17 +02:00
|
|
|
import pygame
|
2023-05-06 14:54:04 +02:00
|
|
|
|
|
|
|
import packageList
|
2023-05-06 13:40:17 +02:00
|
|
|
import regal
|
|
|
|
import wozek
|
2023-05-06 14:54:04 +02:00
|
|
|
from packageList import *
|
|
|
|
from paczka import Paczka
|
2023-05-06 13:40:17 +02:00
|
|
|
|
|
|
|
EKRAN_SZEROKOSC = 980
|
|
|
|
EKRAN_WYSOKOSC = 980
|
|
|
|
screen = pygame.display.set_mode((EKRAN_SZEROKOSC, EKRAN_WYSOKOSC))
|
|
|
|
miejsce = pygame.image.load('images/miejsce_paczek.png')
|
|
|
|
pygame.display.set_caption("Inteligentny wozek")
|
|
|
|
icon = pygame.image.load('images/icon.png')
|
|
|
|
pygame.display.set_icon(icon)
|
|
|
|
|
2023-05-06 14:54:04 +02:00
|
|
|
lista_paczek = packageList.zainicjuj_liste_paczek()
|
2023-05-06 13:40:17 +02:00
|
|
|
|
|
|
|
def narysuj_regaly():
|
|
|
|
regal.Regal(1, 1, 2, 2)
|
|
|
|
regal.Regal(2, 1, 2, 3)
|
|
|
|
regal.Regal(3, 1, 3, 2)
|
|
|
|
regal.Regal(4, 1, 3, 3)
|
|
|
|
|
|
|
|
regal.Regal(5, 1, 10, 2)
|
|
|
|
regal.Regal(6, 1, 10, 3)
|
|
|
|
regal.Regal(7, 1, 11, 2)
|
|
|
|
regal.Regal(8, 1, 11, 3)
|
|
|
|
|
|
|
|
regal.Regal(9, 1, 2, 8)
|
|
|
|
regal.Regal(10, 1, 2, 9)
|
|
|
|
regal.Regal(11, 1, 3, 8)
|
|
|
|
regal.Regal(12, 1, 3, 9)
|
|
|
|
|
|
|
|
regal.Regal(13, 1, 10, 8)
|
|
|
|
regal.Regal(14, 1, 10, 9)
|
|
|
|
regal.Regal(15, 1, 11, 8)
|
|
|
|
regal.Regal(16, 1, 11, 9)
|
|
|
|
|
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):
|
|
|
|
screen.fill((51, 51, 51)) # removes object trail
|
|
|
|
screen.blit(miejsce, (430, 400))
|
2023-05-06 13:53:01 +02:00
|
|
|
narysuj_siatke()
|
2023-05-06 14:54:04 +02:00
|
|
|
narysuj_paczki(wozek)
|
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):
|
|
|
|
if wozek.ln == 0:
|
|
|
|
for paczka in lista_paczek.list:
|
|
|
|
paczka.narysuj(430, 400, screen)
|