diff --git a/__pycache__/agent.cpython-310.pyc b/__pycache__/agent.cpython-310.pyc index 7a51826..df5cf3c 100644 Binary files a/__pycache__/agent.cpython-310.pyc and b/__pycache__/agent.cpython-310.pyc differ diff --git a/__pycache__/archer_ork.cpython-310.pyc b/__pycache__/archer_ork.cpython-310.pyc index 4584ef1..f1cdbcd 100644 Binary files a/__pycache__/archer_ork.cpython-310.pyc and b/__pycache__/archer_ork.cpython-310.pyc differ diff --git a/__pycache__/infantry_ork.cpython-310.pyc b/__pycache__/infantry_ork.cpython-310.pyc index a732aec..e62d8ef 100644 Binary files a/__pycache__/infantry_ork.cpython-310.pyc and b/__pycache__/infantry_ork.cpython-310.pyc differ diff --git a/__pycache__/infantry_ork2.cpython-310.pyc b/__pycache__/infantry_ork2.cpython-310.pyc index c9f3552..4344cfc 100644 Binary files a/__pycache__/infantry_ork2.cpython-310.pyc and b/__pycache__/infantry_ork2.cpython-310.pyc differ diff --git a/__pycache__/sauron.cpython-310.pyc b/__pycache__/sauron.cpython-310.pyc index a9ae9df..a22a84e 100644 Binary files a/__pycache__/sauron.cpython-310.pyc and b/__pycache__/sauron.cpython-310.pyc differ diff --git a/agent.py b/agent.py index 5600741..68fb315 100644 --- a/agent.py +++ b/agent.py @@ -32,6 +32,7 @@ class Agent(pygame.sprite.Sprite): def update(self): self.movement() + self.collide_mob() self.rect.x += self.x_change self.collide_blocks('x') @@ -68,3 +69,36 @@ class Agent(pygame.sprite.Sprite): self.rect.y = hits[0].rect.top - self.rect.height if self.y_change < 0: self.rect.y = hits[0].rect.bottom + + def collide_mob(self): + + hits_archer_ork = pygame.sprite.spritecollide(self, self.game.archer_orks, False) + hits_infantry_ork = pygame.sprite.spritecollide(self, self.game.infantry_orks, False) + hits_infantry_ork2 = pygame.sprite.spritecollide(self, self.game.infantry_orks2, False) + hits_sauron = pygame.sprite.spritecollide(self, self.game.sauronL, False) + if hits_archer_ork: + if self.game.archer_ork.level > self.level: + self.kill() + self.game.new() + else: + self.game.archer_ork.kill() + if hits_infantry_ork: + if self.game.infantry_ork.level > self.level: + self.kill() + self.game.new() + else: + self.game.infantry_ork.kill() + if hits_infantry_ork2: + if self.game.infantry_ork2.level > self.level: + self.kill() + self.game.new() + else: + self.game.infantry_ork2.kill() + if hits_sauron: + if self.game.sauron.level > self.level: + self.kill() + self.game.new() + else: + self.game.sauron.kill() + + # brakuje levelowania postaci gdy zabije moba, jest zrobione tylko, że jeśli za wysoki poziom to ginie i od nowa zaczyna \ No newline at end of file diff --git a/archer_ork.py b/archer_ork.py index 8b886fb..50e1fb7 100644 --- a/archer_ork.py +++ b/archer_ork.py @@ -6,7 +6,7 @@ class Archer_ork(pygame.sprite.Sprite): def __init__(self, game, x, y): self.game = game - self.groups = self.game.all_sprites + self.groups = self.game.all_sprites, self.game.archer_orks pygame.sprite.Sprite.__init__(self, self.groups) self.x = x * TILE_SIZE diff --git a/infantry_ork.py b/infantry_ork.py index 11a77a6..c51d5df 100644 --- a/infantry_ork.py +++ b/infantry_ork.py @@ -6,7 +6,7 @@ class Infantry_ork(pygame.sprite.Sprite): def __init__(self, game, x, y): self.game = game - self.groups = self.game.all_sprites + self.groups = self.game.all_sprites, self.game.infantry_orks pygame.sprite.Sprite.__init__(self, self.groups) self.x = x * TILE_SIZE diff --git a/infantry_ork2.py b/infantry_ork2.py index 2e77bf0..09168e7 100644 --- a/infantry_ork2.py +++ b/infantry_ork2.py @@ -6,7 +6,7 @@ class Infantry_ork2(pygame.sprite.Sprite): def __init__(self, game, x, y): self.game = game - self.groups = self.game.all_sprites + self.groups = self.game.all_sprites, self.game.infantry_orks2 pygame.sprite.Sprite.__init__(self, self.groups) self.x = x * TILE_SIZE diff --git a/main.py b/main.py index 648bdc1..3034e1e 100644 --- a/main.py +++ b/main.py @@ -25,6 +25,10 @@ class Game: def new(self): # tworzy się nowa sesja grania self.all_sprites = pygame.sprite.LayeredUpdates() self.rock_sprites = pygame.sprite.LayeredUpdates() + self.archer_orks = pygame.sprite.LayeredUpdates() + self.infantry_orks = pygame.sprite.LayeredUpdates() + self.infantry_orks2 = pygame.sprite.LayeredUpdates() + self.sauronL = pygame.sprite.LayeredUpdates() self.agent = Agent(self,1,1) self.archer_ork = Archer_ork(self,10,10) self.infantry_ork = Infantry_ork(self,5,1) diff --git a/sauron.py b/sauron.py index bd22ae0..9d05d4a 100644 --- a/sauron.py +++ b/sauron.py @@ -6,7 +6,7 @@ class Sauron(pygame.sprite.Sprite): def __init__(self, game, x, y): self.game = game - self.groups = self.game.all_sprites + self.groups = self.game.all_sprites, self.game.sauronL pygame.sprite.Sprite.__init__(self, self.groups) self.x = x * TILE_SIZE