Merge branch 'movement_and_graphics'
BIN
__pycache__/main.cpython-310.pyc
Normal file
BIN
__pycache__/regal.cpython-310.pyc
Normal file
BIN
images/icon.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
BIN
images/pusty_wozek.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
images/regal.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
images/regal1.png
Normal file
After Width: | Height: | Size: 964 B |
BIN
images/regal2.png
Normal file
After Width: | Height: | Size: 957 B |
BIN
images/regal3.png
Normal file
After Width: | Height: | Size: 957 B |
82
main.py
@ -5,23 +5,20 @@ import paczka
|
||||
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((980, 980))
|
||||
c = (0, 150, 0)
|
||||
|
||||
|
||||
def draw_grid():
|
||||
for y in range(80, 960, 80): # horizontal lines
|
||||
pygame.draw.line(screen, c, (80, y), (960 - 80, y), 1)
|
||||
for x in range(80, 960, 80): # vertical lines
|
||||
pygame.draw.line(screen, c, (x, 80), (x, 960 - 80), 1)
|
||||
|
||||
pygame.display.set_caption("Inteligentny wozek")
|
||||
icon = pygame.image.load('images/icon.png')
|
||||
pygame.display.set_icon(icon)
|
||||
|
||||
class Wozek:
|
||||
def __init__(self):
|
||||
self.x = 55
|
||||
self.y = 55
|
||||
self.x_change = 0
|
||||
self.y_change = 0
|
||||
self.height = 64
|
||||
self.width = 64
|
||||
self.image = pygame.image.load("wozek.png")
|
||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||
# https://www.flaticon.com/free-icons/forklift
|
||||
|
||||
@ -36,33 +33,62 @@ def main():
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit(0)
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
||||
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
||||
sys.exit(0)
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
|
||||
if wozek.y <= 800:
|
||||
wozek.y += 80
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
|
||||
if wozek.y >= 100:
|
||||
wozek.y -= 80
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
|
||||
if wozek.x <= 800:
|
||||
wozek.x += 80
|
||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
|
||||
if wozek.x >= 100:
|
||||
wozek.x -= 80
|
||||
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_DOWN:
|
||||
wozek.y_change = 1
|
||||
if event.key == pygame.K_UP:
|
||||
wozek.y_change = -1
|
||||
if event.key == pygame.K_RIGHT:
|
||||
wozek.x_change = 1
|
||||
if event.key == pygame.K_LEFT:
|
||||
wozek.x_change = -1
|
||||
|
||||
if event.type == pygame.KEYUP:
|
||||
if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
|
||||
wozek.y_change = 0
|
||||
if event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT:
|
||||
wozek.x_change = 0
|
||||
|
||||
wozek.x += wozek.x_change
|
||||
wozek.y += wozek.y_change
|
||||
|
||||
if wozek.x <= 0:
|
||||
wozek.x = 0
|
||||
elif wozek.x >= 916:
|
||||
wozek.x = 916
|
||||
if wozek.y <= 0:
|
||||
wozek.y = 0
|
||||
elif wozek.x >= 916:
|
||||
wozek.x = 916
|
||||
|
||||
# Drawing
|
||||
screen.fill((0, 0, 0)) # removes object trail
|
||||
screen.fill((51,51,51)) # removes object trail
|
||||
|
||||
# idRegału, Długość regału podana w kratkach, Współrzędne od których ma być tworzony regał (wiersz,kolumna) - poziomo
|
||||
# Współrzędne od (1,1) do (10,10)
|
||||
regal1 = regal.Regal(1, 5, 1, 1)
|
||||
regal.Regal(2, 10, 2, 3)
|
||||
regal.Regal(3, 2, 3, 7)
|
||||
regal.Regal(4, 1, 10, 10)
|
||||
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, 8, 2)
|
||||
regal.Regal(6, 1, 8, 3)
|
||||
regal.Regal(7, 1, 9, 2)
|
||||
regal.Regal(8, 1, 9, 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, 8, 8)
|
||||
regal.Regal(14, 1, 8, 9)
|
||||
regal.Regal(15, 1, 9, 8)
|
||||
regal.Regal(16, 1, 9, 9)
|
||||
|
||||
draw_grid()
|
||||
wozek.draw()
|
||||
|
||||
pygame.display.flip() # updating frames
|
||||
|
@ -13,9 +13,7 @@ class Paczka:
|
||||
self.y = 0
|
||||
self.szerokosc = 0
|
||||
self.wysokosc = 0
|
||||
self.image = pygame.image.load("paczka_obrazek.png")
|
||||
self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon)
|
||||
|
||||
self.image = pygame.image.load("images/paczka_obrazek.png")
|
||||
|
||||
# zmienia rozmiar obrazka w zaleznosci od rozmiaru
|
||||
def __dobierz_rozmiar_obrazka(self):
|
||||
|
20
regal.py
@ -21,7 +21,7 @@ def obliczPixeleDlugosciRegalu(self): #Przeliczanie dlugości regału podanego
|
||||
class Regal:
|
||||
def __init__(self, numerRegalu, dlugoscRegaluWKratkach, numerWiersza, numerKolumny):
|
||||
self.numerRegalu = numerRegalu
|
||||
self.wysokoscRegalu = 40
|
||||
self.wysokoscRegalu = 64
|
||||
self.dlugoscRegaluWKratkach = dlugoscRegaluWKratkach
|
||||
self.numerKolumny = numerKolumny
|
||||
|
||||
@ -29,7 +29,23 @@ class Regal:
|
||||
self.kolumna = obliczPixeleNaPodstawieKratek(numerKolumny)
|
||||
self.dlugosc = obliczPixeleDlugosciRegalu(self)
|
||||
|
||||
if(self.numerRegalu >= 0 and self.numerRegalu <= 4):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg.fill((255, 0, 0))
|
||||
reg = pygame.image.load("images/regal.png")
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 5 and self.numerRegalu <= 8):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal1.png")
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 9 and self.numerRegalu <= 12):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal2.png")
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
if(self.numerRegalu >= 13 and self.numerRegalu <= 16):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal3.png")
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
|