diff --git a/__pycache__/agent.cpython-39.pyc b/__pycache__/agent.cpython-39.pyc index 1f547c6..90d37a9 100644 Binary files a/__pycache__/agent.cpython-39.pyc and b/__pycache__/agent.cpython-39.pyc differ diff --git a/__pycache__/archer_ork.cpython-39.pyc b/__pycache__/archer_ork.cpython-39.pyc new file mode 100644 index 0000000..f5b3592 Binary files /dev/null and b/__pycache__/archer_ork.cpython-39.pyc differ diff --git a/__pycache__/config.cpython-39.pyc b/__pycache__/config.cpython-39.pyc index 7f7a30d..4affd1a 100644 Binary files a/__pycache__/config.cpython-39.pyc and b/__pycache__/config.cpython-39.pyc differ diff --git a/__pycache__/infantry_ork.cpython-39.pyc b/__pycache__/infantry_ork.cpython-39.pyc new file mode 100644 index 0000000..60e5016 Binary files /dev/null and b/__pycache__/infantry_ork.cpython-39.pyc differ diff --git a/__pycache__/infantry_ork2.cpython-39.pyc b/__pycache__/infantry_ork2.cpython-39.pyc new file mode 100644 index 0000000..216bcbc Binary files /dev/null and b/__pycache__/infantry_ork2.cpython-39.pyc differ diff --git a/__pycache__/map_add_ons.cpython-39.pyc b/__pycache__/map_add_ons.cpython-39.pyc index 8a55bcc..2405d43 100644 Binary files a/__pycache__/map_add_ons.cpython-39.pyc and b/__pycache__/map_add_ons.cpython-39.pyc differ diff --git a/__pycache__/sauron.cpython-39.pyc b/__pycache__/sauron.cpython-39.pyc new file mode 100644 index 0000000..6220f82 Binary files /dev/null and b/__pycache__/sauron.cpython-39.pyc differ diff --git a/agent.py b/agent.py index f26c158..7ad3f8a 100644 --- a/agent.py +++ b/agent.py @@ -29,9 +29,15 @@ class Agent(pygame.sprite.Sprite): self.rect.y = self.y self.level = 1 - self.health = 10000*self.level + + self.current_health = 500 + self.max_health = 1000 + self.health_bar_length = 300 + self.health_ratio = self.max_health/self.health_bar_length + def update(self): + self.health_bar() self.movement() self.collide_mob() @@ -46,13 +52,13 @@ class Agent(pygame.sprite.Sprite): def movement(self): keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] and self.rect.x > 0: - self.x_change -= TILE_SIZE/2 + self.x_change -= TILE_SIZE if keys[pygame.K_RIGHT] and self.rect.x < 832 - 64: - self.x_change += TILE_SIZE/2 + self.x_change += TILE_SIZE if keys[pygame.K_UP] and self.rect.y > 0: - self.y_change -= TILE_SIZE/2 - if keys[pygame.K_DOWN] and self.rect.y < 832 - 64: - self.y_change += TILE_SIZE/2 + self.y_change -= TILE_SIZE + if keys[pygame.K_DOWN] and self.rect.y < 768 - 64: + self.y_change += TILE_SIZE def collide_blocks(self, direction): if direction == "x": @@ -87,37 +93,37 @@ class Agent(pygame.sprite.Sprite): if hits_archer_ork: - if self.game.archer_ork.level > self.level or self.game.archer_ork.damage > self.health: + if self.game.archer_ork.level > self.level or self.game.archer_ork.damage > self.current_health: self.kill() self.game.new() else: self.game.archer_ork.kill() - self.health=self.health-self.game.archer_ork.damage + self.get_damage(self.game.archer_ork.damage) self.level+=self.level #zmniejszenie życia o damage moba #level up if hits_infantry_ork: - if self.game.infantry_ork.level > self.level or self.game.infantry_ork.damage > self.health: + if self.game.infantry_ork.level > self.level or self.game.infantry_ork.damage > self.current_health: self.kill() self.game.new() else: self.game.infantry_ork.kill() - self.health=self.health-self.game.infantry_ork.damage + self.get_damage(self.game.infantry_ork.damage) self.level+=self.level #zmniejszenie życia o damage moba #level up if hits_infantry_ork2: - if self.game.infantry_ork2.level > self.level or self.game.infantry_ork2.damage > self.health: + if self.game.infantry_ork2.level > self.level or self.game.infantry_ork2.damage > self.current_health: self.kill() self.game.new() else: self.game.infantry_ork2.kill() - self.health=self.health-self.game.infantry_ork2.damage + self.get_damage(self.game.infantry_ork2.damage) self.level+=self.level #zmniejszenie życia o damage moba #level up if hits_sauron: - if self.game.sauron.level > self.level or self.game.sauron.damage > self.health: + if self.game.sauron.level > self.level or self.game.sauron.damage > self.current_health: self.kill() self.game.new() else: @@ -127,6 +133,30 @@ class Agent(pygame.sprite.Sprite): #zmniejszenie życia o damage moba #level up + + def get_damage(self,amount): + if self.current_health > 0: + self.current_health -= amount + if self.current_health <= 0: + self.current_health = 0 + + #zmienic potem na smierc oraz później trzeba będzie tutaj ująć wszystkie statystyki + #i ze statystyk obliczyć ile dmg dostanie agent + + def get_health(self, amount): + if self.current_health < self.max_health: + self.current_health += amount + if self.current_health >= self.max_health: + self.current_health = self.max_health + + def health_bar(self): + pygame.draw.rect(self.game.SCREEN, (255,0,0), (10,780,self.health_bar_length,25)) + pygame.draw.rect(self.game.SCREEN, (0,255,0), (10,780,self.current_health/self.health_ratio,25)) + pygame.draw.rect(self.game.SCREEN, (255,255,255), (10,780,self.health_bar_length, 25),2) + + + + # brakuje levelowania postaci gdy zabije moba, jest zrobione tylko, że jeśli za wysoki poziom, lub brak życia to ginie i od nowa zaczyna # brakuje dodania miejsca w którym agent się leczy diff --git a/main.py b/main.py index ec4a462..03c06e6 100644 --- a/main.py +++ b/main.py @@ -54,7 +54,7 @@ class Game: def map(self): # tworzenie mapy self.clock.tick(FRAMERATE) for x in range(0, WIDTH, TILE_SIZE): - for y in range(0, HEIGHT, TILE_SIZE): + for y in range(0, 768, TILE_SIZE): self.SCREEN.blit(self.BACKGROUND,(x,y)) self.rect = pygame.Rect(x, y, TILE_SIZE, TILE_SIZE) pygame.draw.rect(self.SCREEN, BLACK, self.rect, 1)