-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsounds.py
More file actions
90 lines (67 loc) · 2.2 KB
/
sounds.py
File metadata and controls
90 lines (67 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from typing import Optional
import pygame
NB_POKEMON: int = 151
__all__ : list['Sound'] = []
class Sound(object):
def __init__(self, path: str):
__all__.append(self)
self.path = path
self.sound: Optional[pygame.mixer.Sound] = None
def get(self):
if self.sound is None:
self.load()
return self.sound
def load(self):
if not self.sound:
self.sound = pygame.mixer.Sound(self.path)
def un_load(self):
del self.sound
self.sound = None
def __str__(self):
print("Sound : {}".format(self.path))
BATTLE_DPP_TRAINER = Sound('assets/sound/music/battle_DPP_trainer.mp3')
LEVEL_UP = Sound('assets/sound/level_up.mp3')
HEAL = Sound('assets/sound/heal.mp3')
PLINK = Sound('assets/sound/plink.mp3')
# todo: get file
PLINK_2 = Sound('assets/sound/plink.mp3')
BACK = Sound('assets/sound/plink.mp3')
LVL_UP = Sound('assets/sound/level_up.mp3')
EVOLUTION = Sound('assets/sound/evolution.mp3')
BALL_EXIT = Sound('assets/sound/battle/BallExit.wav')
BALL_SHAKE = Sound('assets/sound/battle/BallShake.wav')
BALL_THROW = Sound('assets/sound/battle/BallThrow.wav')
CATCH = Sound('assets/sound/battle/catch.mp3')
BLOCK = Sound('assets/sound/block.mp3')
SAVE = Sound('assets/sound/save.mp3')
HIT_NORMAL_DAMAGE = Sound('assets/sound/battle/NormalDamage.mp3')
HIT_NOT_VERY_EFFECTIVE = Sound('assets/sound/battle/NotVeryEffective.mp3')
HIT_SUPER_EFFECTIVE = Sound('assets/sound/battle/SuperEffective.mp3')
PC_OPEN = Sound('assets/sound/PCOpen.wav')
PC_CLOSE = Sound('assets/sound/PCClose.wav')
POKE_SOUND: list[Optional[Sound]] = [None] * (NB_POKEMON + 1)
def to_3_digit(num: int) -> str:
if num < 10:
return "00" + str(num)
if num < 100:
return "0" + str(num)
return str(num)
def load_poke_sound():
for id_ in range(1, NB_POKEMON + 1):
sound = Sound(f'assets/sound/cry/{to_3_digit(id_)}Cry.wav')
POKE_SOUND[id_] = sound
def unload_poke_sound():
for ps in POKE_SOUND:
if ps:
ps.un_load()
# __all__ = [
# BATTLE_DPP_TRAINER,
# LEVEL_UP,
# HEAL,
# PLINK,
# BLOCK,
# SAVE,
# HIT_NORMAL_DAMAGE,
# HIT_NOT_VERY_EFFECTIVE,
# HIT_SUPER_EFFECTIVE
# ]