po zabiciu bohater traci zdrowie(testowo ma 10000 zdrowia),po zabiciu moba dostaje +1 lvl, gra sie konczy po zabiciu saurona, porusza sie wolniej(dla wygody)

This commit is contained in:
Paralyzecl 2023-03-31 12:01:43 +02:00
parent 46e766afcc
commit e2d816fcac
2 changed files with 15 additions and 7 deletions

View File

@ -29,7 +29,7 @@ class Agent(pygame.sprite.Sprite):
self.rect.y = self.y self.rect.y = self.y
self.level = 1 self.level = 1
self.health = 100*self.level self.health = 10000*self.level
def update(self): def update(self):
self.movement() self.movement()
@ -46,13 +46,13 @@ class Agent(pygame.sprite.Sprite):
def movement(self): def movement(self):
keys = pygame.key.get_pressed() keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and self.rect.x > 0: if keys[pygame.K_LEFT] and self.rect.x > 0:
self.x_change -= TILE_SIZE self.x_change -= TILE_SIZE/2
if keys[pygame.K_RIGHT] and self.rect.x < 832 - 64: if keys[pygame.K_RIGHT] and self.rect.x < 832 - 64:
self.x_change += TILE_SIZE self.x_change += TILE_SIZE/2
if keys[pygame.K_UP] and self.rect.y > 0: if keys[pygame.K_UP] and self.rect.y > 0:
self.y_change -= TILE_SIZE self.y_change -= TILE_SIZE/2
if keys[pygame.K_DOWN] and self.rect.y < 832 - 64: if keys[pygame.K_DOWN] and self.rect.y < 832 - 64:
self.y_change += TILE_SIZE self.y_change += TILE_SIZE/2
def collide_blocks(self, direction): def collide_blocks(self, direction):
if direction == "x": if direction == "x":
@ -83,6 +83,8 @@ class Agent(pygame.sprite.Sprite):
self.game.new() self.game.new()
else: else:
self.game.archer_ork.kill() self.game.archer_ork.kill()
self.health=self.health-self.game.archer_ork.damage
self.level+=self.level
#zmniejszenie życia o damage moba #zmniejszenie życia o damage moba
#level up #level up
if hits_infantry_ork: if hits_infantry_ork:
@ -91,14 +93,18 @@ class Agent(pygame.sprite.Sprite):
self.game.new() self.game.new()
else: else:
self.game.infantry_ork.kill() self.game.infantry_ork.kill()
self.health=self.health-self.game.infantry_ork.damage
self.level+=self.level
#zmniejszenie życia o damage moba #zmniejszenie życia o damage moba
#level up #level up
if hits_infantry_ork2: if hits_infantry_ork2:
if self.game.infantry_ork2.level > self.level or self.game.infantry2_ork.damage > self.health: if self.game.infantry_ork2.level > self.level or self.game.infantry_ork2.damage > self.health:
self.kill() self.kill()
self.game.new() self.game.new()
else: else:
self.game.infantry_ork2.kill() self.game.infantry_ork2.kill()
self.health=self.health-self.game.infantry_ork2.damage
self.level+=self.level
#zmniejszenie życia o damage moba #zmniejszenie życia o damage moba
#level up #level up
if hits_sauron: if hits_sauron:
@ -107,6 +113,8 @@ class Agent(pygame.sprite.Sprite):
self.game.new() self.game.new()
else: else:
self.game.sauron.kill() self.game.sauron.kill()
self.level+=self.level
pygame.quit()
#zmniejszenie życia o damage moba #zmniejszenie życia o damage moba
#level up #level up

View File

@ -31,7 +31,7 @@ class Game:
self.sauronL = pygame.sprite.LayeredUpdates() self.sauronL = pygame.sprite.LayeredUpdates()
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,5,1) 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)
for y in range(5): for y in range(5):