Compare commits
1 Commits
master
...
put_packag
Author | SHA1 | Date | |
---|---|---|---|
|
bdeb5e87e8 |
46
ekran.py
46
ekran.py
@ -17,27 +17,40 @@ icon = pygame.image.load('images/icon.png')
|
||||
pygame.display.set_icon(icon)
|
||||
|
||||
lista_paczek = packageList.zainicjuj_liste_paczek(a_pix, b_pix)
|
||||
wozek_group = pygame.sprite.Group()
|
||||
regals_collision_group = pygame.sprite.Group()
|
||||
|
||||
def narysuj_regaly():
|
||||
regal.Regal(1, 1, x1, y1)
|
||||
regal.Regal(2, 1, x1, y1+1)
|
||||
regal.Regal(3, 1, x1+1, y1)
|
||||
regal.Regal(4, 1, x1+1, y1+1)
|
||||
regalList = []
|
||||
allRegals = {
|
||||
"aCategory": regalList,
|
||||
"bCategory": regalList,
|
||||
"cCategory": regalList,
|
||||
"dCategory": regalList,
|
||||
}
|
||||
allRegals["aCategory"].append(regal.Regal(1, 1, x1, y1))
|
||||
allRegals["aCategory"].append(regal.Regal(2, 1, x1, y1+1))
|
||||
allRegals["aCategory"].append(regal.Regal(3, 1, x1+1, y1))
|
||||
allRegals["aCategory"].append(regal.Regal(4, 1, x1+1, y1+1))
|
||||
|
||||
regal.Regal(5, 1, x2, y2)
|
||||
regal.Regal(6, 1, x2, y2+1)
|
||||
regal.Regal(7, 1, x2+1, y2)
|
||||
regal.Regal(8, 1, x2+1, y2+1)
|
||||
allRegals["bCategory"].append(regal.Regal(5, 1, x2, y2))
|
||||
allRegals["bCategory"].append(regal.Regal(6, 1, x2, y2+1))
|
||||
allRegals["bCategory"].append(regal.Regal(7, 1, x2+1, y2))
|
||||
allRegals["bCategory"].append(regal.Regal(8, 1, x2+1, y2+1))
|
||||
|
||||
regal.Regal(9, 1, x3, y3)
|
||||
regal.Regal(10, 1, x3, y3+1)
|
||||
regal.Regal(11, 1, x3+1, y3)
|
||||
regal.Regal(12, 1, x3+1, y3+1)
|
||||
allRegals["cCategory"].append(regal.Regal(9, 1, x3, y3))
|
||||
allRegals["cCategory"].append(regal.Regal(10, 1, x3, y3+1))
|
||||
allRegals["cCategory"].append(regal.Regal(11, 1, x3+1, y3))
|
||||
allRegals["cCategory"].append(regal.Regal(12, 1, x3+1, y3+1))
|
||||
|
||||
regal.Regal(13, 1, x4, y4)
|
||||
regal.Regal(14, 1, x4, y4+1)
|
||||
regal.Regal(15, 1, x4+1, y4)
|
||||
regal.Regal(16, 1, x4+1, y4+1)
|
||||
allRegals["dCategory"].append(regal.Regal(13, 1, x4, y4))
|
||||
allRegals["dCategory"].append(regal.Regal(14, 1, x4, y4+1))
|
||||
allRegals["dCategory"].append(regal.Regal(15, 1, x4+1, y4))
|
||||
allRegals["dCategory"].append(regal.Regal(16, 1, x4+1, y4+1))
|
||||
|
||||
for category in allRegals:
|
||||
for regal_obj in allRegals[category]:
|
||||
regals_collision_group.add(regal_obj)
|
||||
|
||||
|
||||
def narysuj_siatke():
|
||||
@ -52,6 +65,7 @@ def narysuj_siatke():
|
||||
def odswiez_ekran(wozek):
|
||||
screen.fill((51, 51, 51)) # removes object trail
|
||||
screen.blit(miejsce,(a_pix, b_pix))
|
||||
|
||||
narysuj_siatke()
|
||||
narysuj_paczki(wozek)
|
||||
narysuj_regaly()
|
||||
|
5
main.py
5
main.py
@ -55,6 +55,11 @@ def main():
|
||||
wozek.drop_package()
|
||||
wozek.dynamic_wozek_picture()
|
||||
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_p:
|
||||
wozek.place_on_shelf(ekran.regals_collision_group, "dolna")
|
||||
|
||||
|
||||
wozek.obecnyStan.x += wozek.x_change
|
||||
wozek.obecnyStan.y += wozek.y_change
|
||||
|
||||
|
8
regal.py
8
regal.py
@ -37,27 +37,33 @@ class Regal(pygame.sprite.Sprite):
|
||||
"gorna": package_storage
|
||||
}
|
||||
|
||||
def place_package(package_name, decision):
|
||||
shelfs[decision].append(package_name)
|
||||
|
||||
if(self.numerRegalu >= 0 and self.numerRegalu <= 4):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
self.rect = reg.get_rect()
|
||||
|
||||
if(self.numerRegalu >= 5 and self.numerRegalu <= 8):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal1.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
self.rect = reg.get_rect()
|
||||
|
||||
if(self.numerRegalu >= 9 and self.numerRegalu <= 12):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal2.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
self.rect = reg.get_rect()
|
||||
|
||||
if(self.numerRegalu >= 13 and self.numerRegalu <= 16):
|
||||
reg = pygame.Surface([self.dlugosc, self.wysokoscRegalu])
|
||||
reg = pygame.image.load("images/regal3.png")
|
||||
self.rect = reg.get_rect()
|
||||
screen.blit(reg, (self.wiersz, self.kolumna))
|
||||
|
||||
self.rect = reg.get_rect()
|
||||
|
11
wozek.py
11
wozek.py
@ -15,6 +15,7 @@ class Wozek(pygame.sprite.Sprite):
|
||||
self.width = 64
|
||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||
self.rect = self.image.get_rect()
|
||||
self.update_position()
|
||||
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||
# https://www.flaticon.com/free-icons/forklift
|
||||
self.__zainicjuj_stan_poczatkowy()
|
||||
@ -41,6 +42,7 @@ class Wozek(pygame.sprite.Sprite):
|
||||
return element
|
||||
else:
|
||||
print("I'm empty!")
|
||||
return None
|
||||
|
||||
def update_position(self, x, y):
|
||||
self.obecnyStan.x = x
|
||||
@ -75,6 +77,15 @@ class Wozek(pygame.sprite.Sprite):
|
||||
# self.add_element(package)
|
||||
# listOfPackages.list.remove(package) # collision doesn't work, collision always happens
|
||||
|
||||
def place_on_shelf(self, spriteGroup,decision):
|
||||
collide = pygame.sprite.spritecollide(self, spriteGroup, False)
|
||||
print(collide)
|
||||
# for regal in collide:
|
||||
# _package_to_place = self.remove_element()
|
||||
# if _package_to_place is not None:
|
||||
# print("dzien dobry jestem w regale")
|
||||
# #regal.place_package(_package_to_place, decision)
|
||||
|
||||
def drop_package(self):
|
||||
package = self.remove_element()
|
||||
if package is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user