Inteligentny_Wozek/ekran.py

82 lines
2.1 KiB
Python
Raw Normal View History

2023-05-06 13:40:17 +02:00
import pygame
2023-05-06 14:54:04 +02:00
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-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')
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-06 14:54:04 +02:00
lista_paczek = packageList.zainicjuj_liste_paczek()
2023-05-06 13:40:17 +02:00
def narysuj_regaly():
2023-05-08 11:27:16 +02:00
regal.Regal(1, 1, x1, y1)
regal.Regal(2, 1, x1, y1+1)
regal.Regal(3, 1, x1+1, y1)
regal.Regal(4, 1, x1+1, y1+1)
2023-05-06 13:40:17 +02:00
2023-05-08 11:27:16 +02:00
regal.Regal(5, 1, x2, y2)
regal.Regal(6, 1, x2, y2+1)
regal.Regal(7, 1, x2+1, y2)
regal.Regal(8, 1, x2+1, y2+1)
2023-05-06 13:40:17 +02:00
2023-05-08 11:27:16 +02:00
regal.Regal(9, 1, x3, y3)
regal.Regal(10, 1, x3, y3+1)
regal.Regal(11, 1, x3+1, y3)
regal.Regal(12, 1, x3+1, y3+1)
2023-05-06 13:40:17 +02:00
2023-05-08 11:27:16 +02:00
regal.Regal(13, 1, x4, y4)
regal.Regal(14, 1, x4, y4+1)
regal.Regal(15, 1, x4+1, y4)
regal.Regal(16, 1, x4+1, y4+1)
2023-05-06 13:40:17 +02:00
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-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:
2023-05-08 11:27:16 +02:00
paczka.narysuj(a_pix, b_pix, screen)