dodawanie domkow bez obslugi bledow
This commit is contained in:
parent
5708e1fe21
commit
c2ff8e4c4b
17
game.py
17
game.py
@ -6,6 +6,7 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import modele
|
import modele
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import random
|
||||||
|
|
||||||
# kolory
|
# kolory
|
||||||
BLACK = (0, 0, 0)
|
BLACK = (0, 0, 0)
|
||||||
@ -32,6 +33,7 @@ WINDOW_SIZE = [980, 980]
|
|||||||
# Tworzenie planszy i kratek
|
# Tworzenie planszy i kratek
|
||||||
plansza = np.array([[modele.Kratka(j, i) for i in range(ILOSC_KOLUMN)]
|
plansza = np.array([[modele.Kratka(j, i) for i in range(ILOSC_KOLUMN)]
|
||||||
for j in range(ILOSC_WIERSZY)])
|
for j in range(ILOSC_WIERSZY)])
|
||||||
|
all_sprites_list = pygame.sprite.Group()
|
||||||
|
|
||||||
# smieciarka
|
# smieciarka
|
||||||
smieciarka = modele.Smieciarka(10, 10)
|
smieciarka = modele.Smieciarka(10, 10)
|
||||||
@ -63,12 +65,25 @@ kontener_szklo.setImage(pygame.image.load(
|
|||||||
"resources/plansza/pojemnik_szklo.png"))
|
"resources/plansza/pojemnik_szklo.png"))
|
||||||
plansza[4, 4].setJestKontenerem(True)
|
plansza[4, 4].setJestKontenerem(True)
|
||||||
|
|
||||||
|
# domy
|
||||||
|
|
||||||
|
doms_array = ['resources/plansza/domy/dom1.png', 'resources/plansza/domy/dom2.png',
|
||||||
|
'resources/plansza/domy/dom3.png', 'resources/plansza/domy/dom4.png', 'resources/plansza/domy/dom5.png']
|
||||||
|
for i in range(0, 5):
|
||||||
|
temp = [random.randint(5, 14), random.randint(5, 14)]
|
||||||
|
print(temp)
|
||||||
|
dom = modele.Dom(temp[0], temp[1])
|
||||||
|
dom.setImage(pygame.image.load(random.choice(doms_array)))
|
||||||
|
plansza[temp[0], temp[1]].setJestDomem(True)
|
||||||
|
all_sprites_list.add(dom)
|
||||||
|
|
||||||
|
|
||||||
# ustawienie wysypiska, rozmiar wysypiska 5x5
|
# ustawienie wysypiska, rozmiar wysypiska 5x5
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
for j in range(5):
|
for j in range(5):
|
||||||
plansza[i, j].setJestWysypiskiem(True)
|
plansza[i, j].setJestWysypiskiem(True)
|
||||||
|
|
||||||
all_sprites_list = pygame.sprite.Group()
|
|
||||||
all_sprites_list.add(kontener_plastik, kontener_metal, kontener_organiczne, kontener_papier, kontener_szklo,
|
all_sprites_list.add(kontener_plastik, kontener_metal, kontener_organiczne, kontener_papier, kontener_szklo,
|
||||||
smieciarka)
|
smieciarka)
|
||||||
|
|
||||||
|
17
modele.py
17
modele.py
@ -67,6 +67,19 @@ class Smieciarka(pygame.sprite.Sprite):
|
|||||||
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
||||||
|
|
||||||
|
|
||||||
|
class Dom(pygame.sprite.Sprite):
|
||||||
|
def __init__(self, x, y):
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
self.image = pygame.image.__class__
|
||||||
|
self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x + MARGIN, self.y * HEIGHT + MARGIN * self.y + MARGIN,
|
||||||
|
WIDTH, HEIGHT)
|
||||||
|
|
||||||
|
def setImage(self, image):
|
||||||
|
self.image = image
|
||||||
|
|
||||||
|
|
||||||
class Kontener(pygame.sprite.Sprite):
|
class Kontener(pygame.sprite.Sprite):
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
self.x = x
|
self.x = x
|
||||||
@ -84,6 +97,7 @@ class Kratka(pygame.sprite.Sprite):
|
|||||||
def __init__(self, poz_x, poz_y):
|
def __init__(self, poz_x, poz_y):
|
||||||
self.pozX = poz_x
|
self.pozX = poz_x
|
||||||
self.pozY = poz_y
|
self.pozY = poz_y
|
||||||
|
self.jestDomem = False
|
||||||
self.jestKontenerem = False
|
self.jestKontenerem = False
|
||||||
self.jestWysypiskiem = False
|
self.jestWysypiskiem = False
|
||||||
self.jestPrzeszkoda = False
|
self.jestPrzeszkoda = False
|
||||||
@ -97,6 +111,9 @@ class Kratka(pygame.sprite.Sprite):
|
|||||||
def setImage(self, image):
|
def setImage(self, image):
|
||||||
self.image = image
|
self.image = image
|
||||||
|
|
||||||
|
def setJestDomem(self, bool):
|
||||||
|
self.jestDomem = bool
|
||||||
|
|
||||||
def setJestSmieciarka(self, bool):
|
def setJestSmieciarka(self, bool):
|
||||||
self.jestSmieciarka = bool
|
self.jestSmieciarka = bool
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user