2023-06-14 12:15:05 +00:00
|
|
|
import pygame
|
|
|
|
from random import randint
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
from configs.system.window_config import TILESIZE
|
|
|
|
|
|
|
|
|
2023-06-14 12:15:05 +00:00
|
|
|
class MagicPlayer:
|
|
|
|
def __init__(self, animation_player):
|
|
|
|
self.animation_player = animation_player
|
2023-11-19 03:27:47 +00:00
|
|
|
|
2023-06-14 12:15:05 +00:00
|
|
|
def heal(self, player, strength, cost, groups):
|
2023-09-27 18:03:37 +00:00
|
|
|
if player.stats.energy >= cost:
|
2023-10-04 02:37:28 +00:00
|
|
|
self.sounds['heal'].play()
|
2023-09-27 18:03:37 +00:00
|
|
|
player.stats.health += strength
|
|
|
|
player.stats.energy -= cost
|
|
|
|
if player.stats.health >= player.stats.stats['health']:
|
|
|
|
player.stats.health = player.stats.stats['health']
|
|
|
|
self.animation_player.generate_particles(
|
2023-11-29 10:53:30 +00:00
|
|
|
'aura',
|
2023-11-29 11:10:04 +00:00
|
|
|
player.animation.rect.center,
|
2023-11-29 10:53:30 +00:00
|
|
|
groups)
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
self.animation_player.generate_particles(
|
2023-11-29 10:53:30 +00:00
|
|
|
'heal',
|
2023-11-29 11:10:04 +00:00
|
|
|
player.animation.rect.center + pygame.math.Vector2(0, -50),
|
2023-11-29 10:53:30 +00:00
|
|
|
groups)
|
2023-09-27 18:03:37 +00:00
|
|
|
|
2023-06-14 12:15:05 +00:00
|
|
|
def flame(self, player, cost, groups):
|
2023-09-27 18:03:37 +00:00
|
|
|
if player.stats.energy >= cost:
|
|
|
|
player.stats.energy -= cost
|
|
|
|
|
2023-10-04 02:37:28 +00:00
|
|
|
if player._input.status.split('_')[0] == 'right':
|
2023-09-27 18:03:37 +00:00
|
|
|
direction = pygame.math.Vector2(1, 0)
|
2023-10-04 02:37:28 +00:00
|
|
|
elif player._input.status.split('_')[0] == 'left':
|
2023-09-27 18:03:37 +00:00
|
|
|
direction = pygame.math.Vector2(-1, 0)
|
2023-10-04 02:37:28 +00:00
|
|
|
elif player._input.status.split('_')[0] == 'up':
|
2023-09-27 18:03:37 +00:00
|
|
|
direction = pygame.math.Vector2(0, -1)
|
2023-06-14 12:15:05 +00:00
|
|
|
else:
|
2023-09-27 18:03:37 +00:00
|
|
|
direction = pygame.math.Vector2(0, 1)
|
|
|
|
|
2023-06-14 12:15:05 +00:00
|
|
|
for i in range(1, 6):
|
|
|
|
if direction.x:
|
|
|
|
offset_x = direction.x * i * TILESIZE
|
2023-11-29 11:10:04 +00:00
|
|
|
x = player.animation.rect.centerx + offset_x + \
|
2023-09-27 18:03:37 +00:00
|
|
|
randint(-TILESIZE // 3, TILESIZE // 3)
|
2023-11-29 11:10:04 +00:00
|
|
|
y = player.animation.rect.centery + \
|
2023-09-27 18:03:37 +00:00
|
|
|
randint(-TILESIZE // 3, TILESIZE // 3)
|
|
|
|
self.animation_player.generate_particles(
|
|
|
|
'flame', (x, y), groups)
|
2023-06-14 12:15:05 +00:00
|
|
|
else:
|
|
|
|
offset_y = direction.y * i * TILESIZE
|
2023-11-29 11:10:04 +00:00
|
|
|
x = player.animation.rect.centerx + \
|
2023-09-27 18:03:37 +00:00
|
|
|
randint(-TILESIZE // 3, TILESIZE // 3)
|
2023-11-29 11:10:04 +00:00
|
|
|
y = player.animation.rect.centery + offset_y + \
|
2023-09-27 18:03:37 +00:00
|
|
|
randint(-TILESIZE // 3, TILESIZE // 3)
|
|
|
|
self.animation_player.generate_particles(
|
|
|
|
'flame', (x, y), groups)
|