forked from s474139/Inteligentny_Wozek
wozek has storage and wozek changes picture based on its load
This commit is contained in:
parent
759f261b2b
commit
486783b5eb
BIN
images/pelny_wozek_1_crate.png
Normal file
BIN
images/pelny_wozek_1_crate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
images/pelny_wozek_2_crates.png
Normal file
BIN
images/pelny_wozek_2_crates.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
images/pelny_wozek_full_3_crates.png
Normal file
BIN
images/pelny_wozek_full_3_crates.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
30
main.py
30
main.py
@ -2,6 +2,7 @@ import sys
|
||||
import pygame
|
||||
import regal
|
||||
import paczka
|
||||
#from wozek import Wozek
|
||||
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((980, 980))
|
||||
@ -11,7 +12,7 @@ pygame.display.set_caption("Inteligentny wozek")
|
||||
icon = pygame.image.load('images/icon.png')
|
||||
pygame.display.set_icon(icon)
|
||||
|
||||
class Wozek:
|
||||
class Wozek():
|
||||
def __init__(self):
|
||||
self.x = 55
|
||||
self.y = 55
|
||||
@ -26,9 +27,34 @@ class Wozek:
|
||||
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():
|
||||
|
||||
wozek = Wozek()
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
|
44
wozek.py
Normal file
44
wozek.py
Normal file
@ -0,0 +1,44 @@
|
||||
from main import pygame, screen
|
||||
|
||||
#screen nie działa
|
||||
|
||||
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))
|
||||
|
||||
#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")
|
Loading…
Reference in New Issue
Block a user