forked from s474139/Inteligentny_Wozek
101 lines
2.9 KiB
Python
101 lines
2.9 KiB
Python
import sys
|
|
import pygame
|
|
import regal
|
|
import paczka
|
|
|
|
pygame.init()
|
|
screen = pygame.display.set_mode((980, 980))
|
|
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)
|
|
|
|
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("images/pusty_wozek.png")
|
|
# 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():
|
|
|
|
wozek = Wozek()
|
|
while True:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
sys.exit(0)
|
|
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
|
sys.exit(0)
|
|
|
|
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((51,51,51)) # removes object trail
|
|
screen.blit(miejsce, (430, 400))
|
|
|
|
# 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)
|
|
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)
|
|
|
|
wozek.draw()
|
|
|
|
pygame.display.flip() # updating frames
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|