dodanie leczenia
This commit is contained in:
parent
2411b49b02
commit
53ad6e8ed1
Binary file not shown.
Binary file not shown.
BIN
__pycache__/health_flower.cpython-310.pyc
Normal file
BIN
__pycache__/health_flower.cpython-310.pyc
Normal file
Binary file not shown.
5
agent.py
5
agent.py
@ -45,6 +45,7 @@ class Agent(pygame.sprite.Sprite):
|
|||||||
self.health_bar()
|
self.health_bar()
|
||||||
self.movement()
|
self.movement()
|
||||||
self.collide_mob()
|
self.collide_mob()
|
||||||
|
self.collide_flower()
|
||||||
#self.end_game() gra sie konczy gdy wie gdzie sa wszyscy
|
#self.end_game() gra sie konczy gdy wie gdzie sa wszyscy
|
||||||
self.disp_level()
|
self.disp_level()
|
||||||
|
|
||||||
@ -96,6 +97,10 @@ class Agent(pygame.sprite.Sprite):
|
|||||||
if (-1 in self.game.state)==False:
|
if (-1 in self.game.state)==False:
|
||||||
pygame.quit()
|
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):
|
def collide_blocks(self, direction):
|
||||||
|
26
health_flower.py
Normal file
26
health_flower.py
Normal file
@ -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
|
3
main.py
3
main.py
@ -6,6 +6,7 @@ from archer_ork import *
|
|||||||
from infantry_ork import *
|
from infantry_ork import *
|
||||||
from infantry_ork2 import *
|
from infantry_ork2 import *
|
||||||
from sauron import *
|
from sauron import *
|
||||||
|
from health_flower import *
|
||||||
#from unknown_mob import * #unknown mob
|
#from unknown_mob import * #unknown mob
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@ -32,12 +33,14 @@ class Game:
|
|||||||
self.infantry_orks = pygame.sprite.LayeredUpdates()
|
self.infantry_orks = pygame.sprite.LayeredUpdates()
|
||||||
self.infantry_orks2 = pygame.sprite.LayeredUpdates()
|
self.infantry_orks2 = pygame.sprite.LayeredUpdates()
|
||||||
self.sauronL = pygame.sprite.LayeredUpdates()
|
self.sauronL = pygame.sprite.LayeredUpdates()
|
||||||
|
self.flowers = pygame.sprite.LayeredUpdates()
|
||||||
#self.unknown_mobs = pygame.sprite.LayeredUpdates() #unknown mob
|
#self.unknown_mobs = pygame.sprite.LayeredUpdates() #unknown mob
|
||||||
self.agent = Agent(self,1,1)
|
self.agent = Agent(self,1,1)
|
||||||
self.archer_ork = Archer_ork(self,10,10)
|
self.archer_ork = Archer_ork(self,10,10)
|
||||||
self.infantry_ork = Infantry_ork(self,10,4)
|
self.infantry_ork = Infantry_ork(self,10,4)
|
||||||
self.infantry_ork2 = Infantry_ork2(self,6,3)
|
self.infantry_ork2 = Infantry_ork2(self,6,3)
|
||||||
self.sauron = Sauron(self, 1, 10)
|
self.sauron = Sauron(self, 1, 10)
|
||||||
|
self.flower = Health_flower(self, 8,2)
|
||||||
#self.unknown_mob = Unknown_mob(self,8,8) #unknown mob
|
#self.unknown_mob = Unknown_mob(self,8,8) #unknown mob
|
||||||
for y in range(5):
|
for y in range(5):
|
||||||
self.rock = Rocks(self,3,y)
|
self.rock = Rocks(self,3,y)
|
||||||
|
BIN
zdjecia/flower.png
Normal file
BIN
zdjecia/flower.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
Loading…
Reference in New Issue
Block a user