From 37931930a6988743a04e7ee1020ac20274ab43b8 Mon Sep 17 00:00:00 2001 From: s444349 Date: Fri, 3 Apr 2020 16:27:21 +0200 Subject: [PATCH] sprawdzanie czy jest przeszkoda --- modele.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modele.py b/modele.py index cc0f1d3..b146e00 100644 --- a/modele.py +++ b/modele.py @@ -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