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