removed audio
This commit is contained in:
parent
60c09ff2c4
commit
b6cfee3775
19 changed files with 50 additions and 114 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,17 +8,6 @@ from configs.system.window_config import TILESIZE
|
|||
class MagicPlayer:
|
||||
def __init__(self, animation_player):
|
||||
self.animation_player = animation_player
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
asset_path = os.path.join(
|
||||
script_dir, '..', 'assets')
|
||||
|
||||
# Sound Setup
|
||||
self.sounds = {
|
||||
'heal': pygame.mixer.Sound(f'{asset_path}/audio/heal.wav'),
|
||||
'flame': pygame.mixer.Sound(f'{asset_path}/audio/flame.wav')
|
||||
}
|
||||
|
||||
self.sounds['flame'].set_volume(0)
|
||||
|
||||
def heal(self, player, strength, cost, groups):
|
||||
if player.stats.energy >= cost:
|
||||
|
@ -35,7 +24,6 @@ class MagicPlayer:
|
|||
def flame(self, player, cost, groups):
|
||||
if player.stats.energy >= cost:
|
||||
player.stats.energy -= cost
|
||||
self.sounds['flame'].play()
|
||||
|
||||
if player._input.status.split('_')[0] == 'right':
|
||||
direction = pygame.math.Vector2(1, 0)
|
||||
|
|
|
@ -79,17 +79,15 @@ class InputHandler:
|
|||
|
||||
self.movement.move(speed, hitbox, obstacle_sprites, rect)
|
||||
|
||||
if self.sprite_type == 'player':
|
||||
# Combat Input
|
||||
if button == 4 and not self.attacking: # keys[pygame.K_e]
|
||||
self.attacking = True
|
||||
self.attack_time = pygame.time.get_ticks()
|
||||
self.combat.create_attack_sprite(player)
|
||||
self.combat.weapon_attack_sound.play()
|
||||
self.action = 4
|
||||
|
||||
# Magic Input
|
||||
if button == 5: # keys[pygame.K_q]:
|
||||
if button == 5:
|
||||
self.attacking = True
|
||||
self.attack_time = pygame.time.get_ticks()
|
||||
|
||||
|
@ -106,7 +104,6 @@ class InputHandler:
|
|||
self.action = 5
|
||||
|
||||
# Rotating Weapons
|
||||
# keys[pygame.K_LSHIFT]
|
||||
if button == 6 and self.can_rotate_weapon:
|
||||
self.can_rotate_weapon = False
|
||||
self.weapon_rotation_time = pygame.time.get_ticks()
|
||||
|
@ -120,7 +117,6 @@ class InputHandler:
|
|||
self.action = 6
|
||||
|
||||
# Swap Spells
|
||||
# keys[pygame.K_LCTRL] :
|
||||
if button == 7 and self.can_swap_magic:
|
||||
self.can_swap_magic = False
|
||||
self.magic_swap_time = pygame.time.get_ticks()
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import os
|
||||
import pygame
|
||||
|
||||
from configs.game.monster_config import monster_data
|
||||
|
||||
|
||||
class AudioHandler:
|
||||
|
||||
def __init__(self, sprite_type, monster_name=None):
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
asset_path = os.path.join(
|
||||
script_dir, '../..', 'assets', 'audio')
|
||||
|
||||
if sprite_type == 'player':
|
||||
pass
|
||||
|
||||
elif sprite_type == 'enemy':
|
||||
|
||||
# Sounds
|
||||
self.attack_sound = pygame.mixer.Sound(
|
||||
monster_data[monster_name]['attack_sound'])
|
||||
self.death_sound = pygame.mixer.Sound(
|
||||
f'{asset_path}/death.wav')
|
||||
self.hit_sound = pygame.mixer.Sound(f'{asset_path}/hit.wav')
|
||||
self.death_sound.set_volume(0)
|
||||
self.hit_sound.set_volume(0)
|
||||
self.attack_sound.set_volume(0)
|
|
@ -1,6 +1,3 @@
|
|||
import os
|
||||
import pygame
|
||||
|
||||
from effects.weapon_effects import Weapon
|
||||
from effects.magic_effects import MagicPlayer
|
||||
|
||||
|
@ -30,15 +27,6 @@ class CombatHandler:
|
|||
self.hurt_time = None
|
||||
self.invulnerability_duration = 300
|
||||
|
||||
# Import Sounds
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
asset_path = os.path.join(
|
||||
script_dir, '../..', 'assets', 'audio')
|
||||
|
||||
self.weapon_attack_sound = pygame.mixer.Sound(
|
||||
f"{asset_path}/sword.wav")
|
||||
self.weapon_attack_sound.set_volume(0)
|
||||
|
||||
def create_attack_sprite(self, player):
|
||||
self.current_attack = Weapon(
|
||||
player, [player.visible_sprites, player.attack_sprites])
|
||||
|
|
|
@ -6,8 +6,6 @@ from .components._input import InputHandler
|
|||
|
||||
from effects.particle_effects import AnimationPlayer
|
||||
|
||||
from .components.audio import AudioHandler
|
||||
|
||||
|
||||
class Enemy(pygame.sprite.Sprite):
|
||||
|
||||
|
@ -19,7 +17,6 @@ class Enemy(pygame.sprite.Sprite):
|
|||
|
||||
self.position = position
|
||||
# Setup Graphics
|
||||
self.audio = AudioHandler(self.sprite_type, self.name)
|
||||
self.animation_player = AnimationPlayer()
|
||||
self.animation = AnimationHandler(self.sprite_type, self.name)
|
||||
self.animation.import_assets(position)
|
||||
|
@ -58,12 +55,10 @@ class Enemy(pygame.sprite.Sprite):
|
|||
self.add_exp(player)
|
||||
self.animation.trigger_death_particles(
|
||||
self.animation_player, self.rect.center, self.name, self.visible_sprites)
|
||||
self.audio.death_sound.play()
|
||||
self.kill()
|
||||
|
||||
def get_damaged(self, player, attack_type):
|
||||
if self._input.combat.vulnerable:
|
||||
self.audio.hit_sound.play()
|
||||
for _, direction, attacking_player in self.distance_direction_from_player:
|
||||
if attacking_player == player:
|
||||
self._input.movement.direction = -direction
|
||||
|
|
|
@ -107,14 +107,15 @@ class Player(pygame.sprite.Sprite):
|
|||
|
||||
self.action_features = [self._input.action]
|
||||
|
||||
self.reward_features = [self.stats.exp,
|
||||
self.reward_features = [
|
||||
1 - np.exp(-self.stats.exp),
|
||||
np.exp(-(nearest_dist)),
|
||||
np.exp(-(nearest_enemy.stats.health)),
|
||||
- np.exp(self.stats.health)
|
||||
- np.exp(-self.stats.health)
|
||||
]
|
||||
|
||||
self.state_features = [
|
||||
# TODO: Find a way to normalize
|
||||
# TODO: Find a way to not use magic numbers
|
||||
self.rect.center[0]/3616,
|
||||
self.rect.center[1]/3168,
|
||||
self._input.movement.direction.x,
|
||||
|
@ -126,14 +127,14 @@ class Player(pygame.sprite.Sprite):
|
|||
enemy_states = []
|
||||
|
||||
for distance, direction, enemy in sorted_distances[:5]:
|
||||
|
||||
# TODO: Find a way to not use magic numbers
|
||||
enemy_states.extend([
|
||||
distance/sorted_distances[-1][0],
|
||||
direction[0],
|
||||
direction[1],
|
||||
enemy.stats.health/enemy.stats.monster_info['health'],
|
||||
enemy.stats.attack/enemy.stats.monster_info['attack'],
|
||||
enemy.stats.exp/enemy.stats.monster_info['exp'],
|
||||
enemy.stats.exp/250,
|
||||
])
|
||||
|
||||
self.state_features.extend(enemy_states)
|
||||
|
|
5
game.py
5
game.py
|
@ -18,11 +18,6 @@ class Game:
|
|||
|
||||
self.level = Level()
|
||||
|
||||
# Sound
|
||||
main_sound = pygame.mixer.Sound('assets/audio/main.ogg')
|
||||
main_sound.set_volume(0)
|
||||
main_sound.play(loops=-1)
|
||||
|
||||
def run(self):
|
||||
|
||||
for event in pygame.event.get():
|
||||
|
|
4
main.py
4
main.py
|
@ -6,7 +6,7 @@ environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
n_episodes = 1
|
||||
n_episodes = 3000
|
||||
|
||||
figure_file = 'plots/score.png'
|
||||
score_history = []
|
||||
|
@ -15,7 +15,7 @@ if __name__ == '__main__':
|
|||
|
||||
agent_list = []
|
||||
|
||||
game_len = 1
|
||||
game_len = 5000
|
||||
|
||||
game = Game()
|
||||
|
||||
|
|
BIN
tmp/ppo/actor_torch_ppo
Normal file
BIN
tmp/ppo/actor_torch_ppo
Normal file
Binary file not shown.
BIN
tmp/ppo/critic_torch_ppo
Normal file
BIN
tmp/ppo/critic_torch_ppo
Normal file
Binary file not shown.
Loading…
Reference in a new issue