Inteligentny_Wozek/ekran.py

63 lines
1.7 KiB
Python
Raw Normal View History

2023-05-06 13:40:17 +02:00
import pygame
import regal
import wozek
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)
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)
def drawGrid():
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, (430, 400))
drawGrid()
narysuj_regaly()
wozek.draw()
# pygame.draw.rect(screen, (255,0,0),(70,70,10,10))
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