2023-03-10 23:21:14 +01:00
|
|
|
import sys
|
2023-03-21 12:36:50 +01:00
|
|
|
import pygame
|
|
|
|
import regal
|
2023-03-26 18:13:07 +02:00
|
|
|
import paczka
|
2023-03-10 23:21:14 +01:00
|
|
|
|
|
|
|
pygame.init()
|
2023-03-11 13:46:05 +01:00
|
|
|
screen = pygame.display.set_mode((980, 980))
|
2023-03-11 13:26:14 +01:00
|
|
|
|
2023-03-26 21:21:52 +02:00
|
|
|
pygame.display.set_caption("Inteligentny wozek")
|
|
|
|
icon = pygame.image.load('images/icon.png')
|
|
|
|
pygame.display.set_icon(icon)
|
2023-03-11 13:26:14 +01:00
|
|
|
|
2023-03-11 00:44:46 +01:00
|
|
|
class Wozek:
|
|
|
|
def __init__(self):
|
|
|
|
self.x = 55
|
|
|
|
self.y = 55
|
2023-03-26 21:21:52 +02:00
|
|
|
self.x_change = 0
|
|
|
|
self.y_change = 0
|
2023-03-11 00:44:46 +01:00
|
|
|
self.height = 64
|
|
|
|
self.width = 64
|
2023-03-26 21:21:52 +02:00
|
|
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
2023-03-11 00:44:46 +01:00
|
|
|
# Credit: Forklift icons created by Smashicons - Flaticon
|
|
|
|
# https://www.flaticon.com/free-icons/forklift
|
|
|
|
|
|
|
|
def draw(self):
|
|
|
|
screen.blit(self.image, (self.x, self.y))
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2023-03-21 12:36:50 +01:00
|
|
|
|
2023-03-11 00:44:46 +01:00
|
|
|
wozek = Wozek()
|
|
|
|
while True:
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
sys.exit(0)
|
2023-03-26 21:21:52 +02:00
|
|
|
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
2023-03-11 00:44:46 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
2023-03-26 21:21:52 +02:00
|
|
|
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
|
2023-03-21 12:36:50 +01:00
|
|
|
|
2023-03-11 13:26:14 +01:00
|
|
|
# Drawing
|
2023-03-26 21:21:52 +02:00
|
|
|
screen.fill((51,51,51)) # removes object trail
|
2023-03-21 12:36:50 +01:00
|
|
|
|
|
|
|
# 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)
|
2023-03-26 21:21:52 +02:00
|
|
|
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)
|
2023-03-21 12:36:50 +01:00
|
|
|
|
2023-03-11 00:44:46 +01:00
|
|
|
wozek.draw()
|
2023-03-21 12:36:50 +01:00
|
|
|
|
2023-03-11 13:26:14 +01:00
|
|
|
pygame.display.flip() # updating frames
|
2023-03-11 00:44:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|