Compare commits

..

No commits in common. "a90c30ae321a9641f15e7eb09c491841d5daf25a" and "48c4833ec86c2c18799a459f1f7d489213f2d5b1" have entirely different histories.

5 changed files with 77 additions and 88 deletions

View File

@ -1,10 +1,16 @@
#from main import pygame
import secrets, string import secrets, string
class Etykieta: class Etykieta:
def __init__(self, nadawca, adres, imie, nazwisko, telefon): def __init__(self, id, nadawca, adres, imie, nazwisko, telefon):
self.nadawca = nadawca self.nadawca = nadawca
self.adres = adres self.adres = adres
self.imie = imie self.imie = imie
self.nazwisko = nazwisko self.nazwisko = nazwisko
self.telefon = telefon self.telefon = telefon
self.id = ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(9)) self.id = ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(9))

65
main.py
View File

@ -1,9 +1,8 @@
import sys import sys
import pygame import pygame
import regal import regal
from paczka import Paczka import paczka
from wozek import Wozek #from wozek import Wozek
from packageList import listOfPackages
pygame.init() pygame.init()
screen = pygame.display.set_mode((980, 980)) screen = pygame.display.set_mode((980, 980))
@ -13,17 +12,50 @@ pygame.display.set_caption("Inteligentny wozek")
icon = pygame.image.load('images/icon.png') icon = pygame.image.load('images/icon.png')
pygame.display.set_icon(icon) pygame.display.set_icon(icon)
def draw(self): class Wozek():
screen.blit(self.image, (self.x, self.y)) 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))
#storage = ["none"] * 10
storage = []
max_size = 10
def add_element(element, storage, max_size):
if len(storage) < max_size:
storage.append(element)
else:
print("I'm full!")
def remove_element(storage):
if len(storage) > 0:
place = storage.pop()
return place
else:
print("I'm empty!")
def dynamic_wozek_picture(wozek, storage):
if len(storage) == 0:
wozek.image = pygame.image.load("images/pusty_wozek.png")
elif ((len(storage) > 0) and (len(storage) < 4)):
wozek.image = pygame.image.load("images/pelny_wozek_1_crate.png")
elif ((len(storage) > 3) and (len(storage) < 10)):
wozek.image = pygame.image.load("images/pelny_wozek_2_crates.png")
elif (len(storage) == 10):
wozek.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
def main(): def main():
wozek = Wozek() wozek = Wozek()
packageList = listOfPackages()
demo_paczka = Paczka('duzy', 10, any, False, any, any, any, any, any)
packageList.add(demo_paczka)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
@ -47,15 +79,6 @@ def main():
if event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT: if event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT:
wozek.x_change = 0 wozek.x_change = 0
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
if wozek.ln == 0:
wozek.load_package()
wozek.dynamic_wozek_picture()
else:
wozek.drop_package()
wozek.dynamic_wozek_picture()
wozek.x += wozek.x_change wozek.x += wozek.x_change
wozek.y += wozek.y_change wozek.y += wozek.y_change
@ -94,11 +117,7 @@ def main():
regal.Regal(15, 1, 9, 8) regal.Regal(15, 1, 9, 8)
regal.Regal(16, 1, 9, 9) regal.Regal(16, 1, 9, 9)
draw(wozek) wozek.draw()
if wozek.ln == 0:
for x in packageList.list:
draw(x)
#demo_paczka.narysuj(430,400,screen)
pygame.display.flip() # updating frames pygame.display.flip() # updating frames

View File

@ -1,8 +0,0 @@
class listOfPackages:
list = []
def add(self, item):
self.list.append(item)
def remove(self):
self.list.pop()

View File

@ -6,29 +6,14 @@ class Paczka:
def __init__(self, rozmiar, waga, kategoria, czy_krucha, nadawca, adres, imie, nazwisko, telefon): def __init__(self, rozmiar, waga, kategoria, czy_krucha, nadawca, adres, imie, nazwisko, telefon):
self.rozmiar = rozmiar self.rozmiar = rozmiar
self.image = pygame.image.load("images/paczka.png")
if rozmiar == 'duzy':
self.image = pygame.transform.scale(self.image, (50, 50))
self.szerokosc = 50
self.wysokosc = 50
elif rozmiar == 'sredni':
self.image = pygame.transform.scale(self.image, (35, 35))
self.szerokosc = 35
self.wysokosc = 35
elif rozmiar == 'maly':
self.image = pygame.transform.scale(self.image, (20, 20))
self.szerokosc = 20
self.wysokosc = 20
else:
self.image = pygame.transform.scale(self.image, (20, 20))
self.szerokosc = 20
self.wysokosc = 20
self.rozmiar = 'undefined'
self.waga = waga self.waga = waga
self.kategoria = kategoria self.kategoria = kategoria
self.czy_krucha = czy_krucha self.czy_krucha = czy_krucha
self.x = 430 self.x = 0
self.y = 400 self.y = 0
self.szerokosc = 0
self.wysokosc = 0
self.image = pygame.image.load("images/paczka.png")
self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon) self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon)
# zmienia rozmiar obrazka w zaleznosci od rozmiaru # zmienia rozmiar obrazka w zaleznosci od rozmiaru

View File

@ -1,5 +1,6 @@
import pygame,math from main import pygame, screen
from packageList import listOfPackages
#screen nie działa
class Wozek(): class Wozek():
def __init__(self): def __init__(self):
@ -13,45 +14,31 @@ class Wozek():
# Credit: Forklift icons created by Smashicons - Flaticon # Credit: Forklift icons created by Smashicons - Flaticon
# https://www.flaticon.com/free-icons/forklift # https://www.flaticon.com/free-icons/forklift
def draw(self):
screen.blit(self.image, (self.x, self.y))
#storage = ["none"] * 10 #storage = ["none"] * 10
storage = [] storage = []
max_size = 10 max_size = 10
ln = len(storage)
def add_element(self, element): def add_element(element, storage, max_size):
if self.ln < self.max_size: if len(storage) < max_size:
self.storage.append(element) storage.append(element)
self.ln=self.ln+1
else: else:
print("I'm full!") print("I'm full!")
def remove_element(self): def remove_element(storage):
if self.ln > 0: if len(storage) > 0:
element = self.storage.pop() place = storage.pop()
self.ln=self.ln-1 return place
return element
else: else:
print("I'm empty!") print("I'm empty!")
def dynamic_wozek_picture(self): def dynamic_wozek_picture(wozek, storage):
if self.ln == 0: if len(storage) == 0:
self.image = pygame.image.load("images/pusty_wozek.png") wozek.image = pygame.image.load("images/pusty_wozek.png")
elif ((self.ln > 0) and (self.ln < 4)): elif ((len(storage) > 0) and (len(storage) < 4)):
self.image = pygame.image.load("images/pelny_wozek_1_crate.png") wozek.image = pygame.image.load("images/pelny_wozek_1_crate.png")
elif ((self.ln > 3) and (self.ln < 10)): elif ((len(storage) > 3) and (len(storage) < 10)):
self.image = pygame.image.load("images/pelny_wozek_2_crates.png") wozek.image = pygame.image.load("images/pelny_wozek_2_crates.png")
elif (self.ln == 10): elif (len(storage) == 10):
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png") wozek.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
def load_package(self):
for package in listOfPackages.list:
dist = math.sqrt((self.x - package.x)**2 + (self.y - package.y)**2)
if dist <= 50:
self.add_element(package)
listOfPackages.list.pop()
def drop_package(self):
package = self.remove_element()
if package is not None:
listOfPackages.list.append(package)
package.x = self.x+50
package.y = self.y