forked from s474139/Inteligentny_Wozek
Merge pull request 'adding package class' (#4) from added_package_class into master
Reviewed-on: s474139/Inteligentny_Wozek#4
This commit is contained in:
commit
6f3ce87ac2
45
paczka.py
Normal file
45
paczka.py
Normal file
@ -0,0 +1,45 @@
|
||||
from main import pygame
|
||||
|
||||
|
||||
class Paczka:
|
||||
|
||||
def __init__(self, rozmiar, waga, kategoria, czy_krucha):
|
||||
self.rozmiar = rozmiar
|
||||
self.waga = waga
|
||||
self.kategoria = kategoria
|
||||
self.czy_krucha = czy_krucha
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.szerokosc = 0
|
||||
self.wysokosc = 0
|
||||
self.image = pygame.image.load("paczka_obrazek.png")
|
||||
|
||||
# zmienia rozmiar obrazka w zaleznosci od rozmiaru
|
||||
def __dobierz_rozmiar_obrazka(self):
|
||||
if self.rozmiar == "duzy":
|
||||
self.image = pygame.transform.scale(self.image, (50, 50))
|
||||
self.szerokosc = 50
|
||||
self.wysokosc = 50
|
||||
return 1
|
||||
elif self.rozmiar == "sredni":
|
||||
self.image = pygame.transform.scale(self.image, (35, 35))
|
||||
self.szerokosc = 35
|
||||
self.wysokosc = 35
|
||||
return 1
|
||||
elif self.rozmiar == "maly":
|
||||
self.image = pygame.transform.scale(self.image, (20, 20))
|
||||
self.szerokosc = 20
|
||||
self.wysokosc = 20
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
def narysuj(self, x, y, screen):
|
||||
self.x = x
|
||||
self.y = y
|
||||
if self.__dobierz_rozmiar_obrazka() == 1:
|
||||
screen.blit(self.image, (self.x, self.y))
|
||||
else:
|
||||
print("Zmien rozmiar paczki")
|
||||
print("Paczka moze miec rozmiar duzy, sredni lub maly")
|
||||
exit(0)
|
BIN
paczka_obrazek.png
Normal file
BIN
paczka_obrazek.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue
Block a user