diff --git a/__pycache__/agent.cpython-310.pyc b/__pycache__/agent.cpython-310.pyc index 124cd4b..e4f2ddb 100644 Binary files a/__pycache__/agent.cpython-310.pyc and b/__pycache__/agent.cpython-310.pyc differ diff --git a/__pycache__/config.cpython-310.pyc b/__pycache__/config.cpython-310.pyc index 3e5759b..39121ba 100644 Binary files a/__pycache__/config.cpython-310.pyc and b/__pycache__/config.cpython-310.pyc differ diff --git a/__pycache__/health_flower.cpython-310.pyc b/__pycache__/health_flower.cpython-310.pyc new file mode 100644 index 0000000..2911eff Binary files /dev/null and b/__pycache__/health_flower.cpython-310.pyc differ diff --git a/agent.py b/agent.py index f9034a5..a8fdc8d 100644 --- a/agent.py +++ b/agent.py @@ -45,6 +45,7 @@ class Agent(pygame.sprite.Sprite): self.health_bar() self.movement() self.collide_mob() + self.collide_flower() #self.end_game() gra sie konczy gdy wie gdzie sa wszyscy self.disp_level() @@ -96,6 +97,10 @@ class Agent(pygame.sprite.Sprite): if (-1 in self.game.state)==False: pygame.quit() + def collide_flower(self): + hits_flower = pygame.sprite.spritecollide(self, self.game.flowers, False) + if hits_flower: + self.current_health = self.max_health def collide_blocks(self, direction): diff --git a/health_flower.py b/health_flower.py new file mode 100644 index 0000000..fd001cf --- /dev/null +++ b/health_flower.py @@ -0,0 +1,26 @@ +import pygame +from config import * + +class Health_flower(pygame.sprite.Sprite): + + + def __init__(self, game, x, y): + self.game = game + self.groups = self.game.all_sprites, self.game.flowers + pygame.sprite.Sprite.__init__(self, self.groups) + + self.x = x * TILE_SIZE + self.y = y * TILE_SIZE + self.width = TILE_SIZE + self.height = TILE_SIZE + + self.FLOWER_IMG = pygame.image.load("./zdjecia/flower.png") + self.FLOWER = pygame.transform.scale(self.FLOWER_IMG,(64,64)) + + self.image = pygame.Surface([self.width, self.height]) + self.image.blit(self.FLOWER, (0,0)) + self.image.set_colorkey((0, 0, 0)) + + self.rect = self.image.get_rect() + self.rect.x = self.x + self.rect.y = self.y diff --git a/main.py b/main.py index 031a512..d2b69f3 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ from archer_ork import * from infantry_ork import * from infantry_ork2 import * from sauron import * +from health_flower import * #from unknown_mob import * #unknown mob class Game: @@ -32,12 +33,14 @@ class Game: self.infantry_orks = pygame.sprite.LayeredUpdates() self.infantry_orks2 = pygame.sprite.LayeredUpdates() self.sauronL = pygame.sprite.LayeredUpdates() + self.flowers = pygame.sprite.LayeredUpdates() #self.unknown_mobs = pygame.sprite.LayeredUpdates() #unknown mob self.agent = Agent(self,1,1) self.archer_ork = Archer_ork(self,10,10) self.infantry_ork = Infantry_ork(self,10,4) self.infantry_ork2 = Infantry_ork2(self,6,3) self.sauron = Sauron(self, 1, 10) + self.flower = Health_flower(self, 8,2) #self.unknown_mob = Unknown_mob(self,8,8) #unknown mob for y in range(5): self.rock = Rocks(self,3,y) diff --git a/zdjecia/flower.png b/zdjecia/flower.png new file mode 100644 index 0000000..4805e9e Binary files /dev/null and b/zdjecia/flower.png differ