diff --git a/game.py b/game.py index dc74101..3b35aa9 100644 --- a/game.py +++ b/game.py @@ -105,7 +105,7 @@ def game(): print("Click ", pozycja_myszki, "Grid coordinates: ", wiersz, kolumna) - plansza[wiersz, kolumna].setKolor(BLUE) + # plansza[wiersz, kolumna].setKolor(BLUE) elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: @@ -118,7 +118,8 @@ def game(): smieciarka.w_dol() # Limit to 60 frames per second - clock.tick(60) + smieciarka.rand_move() + clock.tick(5) # czarny kolor w tle obraz.fill(BLACK) diff --git a/modele.py b/modele.py index cc0f1d3..e5f5e81 100644 --- a/modele.py +++ b/modele.py @@ -1,4 +1,6 @@ import pygame +import random + # This sets the WIDTH and HEIGHT of each grid location WIDTH = 60 @@ -26,6 +28,17 @@ class Smieciarka(pygame.sprite.Sprite): self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x + MARGIN, self.y * HEIGHT + MARGIN * self.y, WIDTH, HEIGHT) + def rand_move(self): + rand_int = random.randint(0, 20) + if(rand_int >= 0 and rand_int < 5): + self.w_lewo() + elif(rand_int >= 5 and rand_int < 10): + self.w_prawo() + elif(rand_int >= 10 and rand_int < 15): + self.w_gore() + elif(rand_int >= 15 and rand_int < 20): + self.w_dol() + def w_lewo(self): if self.x > 0: self.x -= 1