naprawione indexowanie
This commit is contained in:
parent
d54adddfaa
commit
ab6ad4f2f8
10
game.py
10
game.py
@ -30,12 +30,13 @@ ILOSC_KOLUMN = 15
|
||||
WINDOW_SIZE = [980, 980]
|
||||
|
||||
# Tworzenie planszy i kratek
|
||||
plansza = np.array([[modele.Kratka(j, i) for i in range(ILOSC_KOLUMN)]
|
||||
for j in range(ILOSC_WIERSZY)])
|
||||
plansza = np.array([[modele.Kratka(i, j) for i in range(ILOSC_KOLUMN)] for j in range(ILOSC_WIERSZY)])
|
||||
|
||||
|
||||
# smieciarka
|
||||
smieciarka = modele.Smieciarka(10, 10)
|
||||
plansza[10, 10].setJestSmieciarka(True)
|
||||
plansza[10, 10].setKolor(BLUE)
|
||||
|
||||
# kontenery
|
||||
kontener_plastik = modele.Kontener(0, 0)
|
||||
@ -118,8 +119,7 @@ def game():
|
||||
smieciarka.w_dol()
|
||||
|
||||
# Limit to 60 frames per second
|
||||
smieciarka.rand_move()
|
||||
clock.tick(5)
|
||||
clock.tick(1)
|
||||
|
||||
# czarny kolor w tle
|
||||
obraz.fill(BLACK)
|
||||
@ -138,7 +138,7 @@ def game():
|
||||
obraz.blit(pygame.image.load(
|
||||
"resources/plansza/wysypisko.jpg"), (5, 5))
|
||||
all_sprites_list.draw(obraz)
|
||||
|
||||
smieciarka.rand_move()
|
||||
# Go ahead and update the screen with what we've drawn.
|
||||
pygame.display.flip()
|
||||
|
||||
|
10
modele.py
10
modele.py
@ -43,34 +43,44 @@ class Smieciarka(pygame.sprite.Sprite):
|
||||
if self.x > 0:
|
||||
if game.plansza[self.x - 1, self.y].jestPrzeszkoda is not True:
|
||||
self.x -= 1
|
||||
game.plansza[self.x,self.y].setKolor(BLUE)
|
||||
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
|
||||
if self.ruch == 2:
|
||||
self.image = pygame.image.load(
|
||||
'resources/plansza/smieciarka.png')
|
||||
self.ruch = 1
|
||||
|
||||
|
||||
|
||||
def w_prawo(self):
|
||||
if self.x < 14:
|
||||
if game.plansza[self.x + 1, self.y].jestPrzeszkoda is not True:
|
||||
self.x += 1
|
||||
game.plansza[self.x, self.y].setKolor(BLUE)
|
||||
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
|
||||
if self.ruch == 1:
|
||||
self.image = pygame.transform.flip(self.image, True, False)
|
||||
self.ruch = 2
|
||||
|
||||
|
||||
def w_gore(self):
|
||||
if self.y > 0:
|
||||
if game.plansza[self.x, self.y - 1].jestPrzeszkoda is not True:
|
||||
self.y -= 1
|
||||
game.plansza[self.x, self.y].setKolor(BLUE)
|
||||
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
||||
|
||||
|
||||
def w_dol(self):
|
||||
if self.y < 14:
|
||||
if game.plansza[self.x, self.y + 1].jestPrzeszkoda is not True:
|
||||
self.y += 1
|
||||
game.plansza[self.x, self.y].setKolor(BLUE)
|
||||
self.rect.y = self.y * HEIGHT + self.y * MARGIN
|
||||
|
||||
|
||||
|
||||
|
||||
class Kontener(pygame.sprite.Sprite):
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
|
Loading…
Reference in New Issue
Block a user