sprawdzanie czy jest przeszkoda

This commit is contained in:
s444349 2020-04-03 16:27:21 +02:00
parent a7d4492559
commit 37931930a6

View File

@ -1,4 +1,5 @@
import pygame
import game
# This sets the WIDTH and HEIGHT of each grid location
WIDTH = 60
@ -27,7 +28,7 @@ class Smieciarka(pygame.sprite.Sprite):
HEIGHT)
def w_lewo(self):
if self.x > 0:
if self.x > 0 or game.plansza[self.x - 1, self.y].jestPrzeszkoda is not True:
self.x -= 1
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
if self.ruch == 2:
@ -36,7 +37,7 @@ class Smieciarka(pygame.sprite.Sprite):
self.ruch = 1
def w_prawo(self):
if self.x < 14:
if self.x < 14 or game.plansza[self.x + 1, self.y].jestPrzeszkoda is not True:
self.x += 1
self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN
if self.ruch == 1:
@ -44,12 +45,12 @@ class Smieciarka(pygame.sprite.Sprite):
self.ruch = 2
def w_gore(self):
if self.y > 0:
if self.y > 0 or game.plansza[self.x, self.y - 1].jestPrzeszkoda is not True:
self.y -= 1
self.rect.y = self.y * HEIGHT + self.y * MARGIN
def w_dol(self):
if self.y < 14:
if self.y < 14 or game.plansza[self.x, self.y + 1].jestPrzeszkoda is not True:
self.y += 1
self.rect.y = self.y * HEIGHT + self.y * MARGIN
@ -71,9 +72,9 @@ class Kratka(pygame.sprite.Sprite):
def __init__(self, poz_x, poz_y):
self.pozX = poz_x
self.pozY = poz_y
self.jestSmieciarka = False
self.jestKontenerem = False
self.jestWysypiskiem = False
self.jestPrzeszkoda = False
self.kolor = GREY
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.__class__
@ -87,6 +88,9 @@ class Kratka(pygame.sprite.Sprite):
def setJestSmieciarka(self, bool):
self.jestSmieciarka = bool
def setJestPrzeszkoda(self, bool):
self.jestPrzeszkoda = bool
def setJestKontenerem(self, bool):
self.jestKontenerem = bool