forked from s474139/Inteligentny_Wozek
82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
import pygame
|
|
|
|
from plansza import x1, y1, x2, y2, x3, y3, x4, y4, a_pix, b_pix
|
|
import packageList
|
|
import regal
|
|
import wozek
|
|
from packageList import *
|
|
from paczka import Paczka
|
|
|
|
EKRAN_SZEROKOSC = 980
|
|
EKRAN_WYSOKOSC = 980
|
|
screen = pygame.display.set_mode((EKRAN_SZEROKOSC, EKRAN_WYSOKOSC))
|
|
miejsce = pygame.image.load('images/miejsce_paczek.png')
|
|
miejsce = pygame.transform.scale(miejsce, (140, 140))
|
|
pygame.display.set_caption("Inteligentny wozek")
|
|
icon = pygame.image.load('images/icon.png')
|
|
pygame.display.set_icon(icon)
|
|
|
|
lista_paczek = packageList.zainicjuj_liste_paczek()
|
|
|
|
def narysuj_regaly():
|
|
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)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
|
|
def narysuj_siatke():
|
|
blockSize = 70 # Set the size of the grid block
|
|
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)
|
|
|
|
|
|
def odswiez_ekran(wozek):
|
|
screen.fill((51, 51, 51)) # removes object trail
|
|
screen.blit(miejsce,(a_pix, b_pix))
|
|
narysuj_siatke()
|
|
narysuj_paczki(wozek)
|
|
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
|
|
|
|
|
|
def sprawdz_ktora_kolumna(y):
|
|
nr_kolumny = 0
|
|
for i in range(70, EKRAN_SZEROKOSC + 70, 70):
|
|
if y < i:
|
|
return nr_kolumny
|
|
nr_kolumny = nr_kolumny + 1
|
|
|
|
|
|
def narysuj_paczki(wozek):
|
|
if wozek.ln == 0:
|
|
for paczka in lista_paczek.list:
|
|
paczka.narysuj(a_pix, b_pix, screen)
|