@@ -22,27 +22,36 @@ static const char sound_open_parchemin[] =
2222 "./assets/music/sound/paper.ogg" ;
2323static const char sound_level_up [] =
2424 "./assets/music/sound/level_up_sound.ogg" ;
25- const char MUSIC_GAME [] = "musicgame" ;
26- static const char music_in_game [] =
27- "./assets/music/game_music.ogg" ;
28- static const int layer = 0 ;
25+ static const char sound_ninho [] =
26+ "./assets/music/sound/ninho_sound.ogg" ;
2927
30- static int init_win_component_music (window_t * win , scene_t * scene ,
31- const char * key_to_get , const char * path_to_data )
32- {
33- object_t * obj = NULL ;
28+ const int layer = 0 ;
3429
35- if (scene == NULL || win == NULL ) {
36- return RET_ERR_INPUT ;
37- }
38- obj = create_object (NULL , NULL , scene , layer );
39- if (object_set_audio (obj , path_to_data , false, false) != BGS_OK ) {
40- return RET_ERR_MALLOC ;
41- }
42- add_new_audio (obj , win );
43- window_add_component (win , obj , key_to_get , NULL );
44- return RET_OK ;
45- }
30+ static const char * keys_to_get [] = {
31+ HURTED_SOUND ,
32+ HURT_SOUNG ,
33+ OPEN_INV_SOUND ,
34+ CLOSE_INV_SOUND ,
35+ CONSUM_CAN_SOUND ,
36+ INFINITY_86_SOUND ,
37+ PARCHEMIN_SOUND ,
38+ LEVEL_UP_SOUND ,
39+ NINHO ,
40+ NULL
41+ };
42+
43+ static const char * paths_to_data_sound [] = {
44+ sound_hited_path ,
45+ sound_hit_path ,
46+ sound_open_fridge ,
47+ sound_close_fridge ,
48+ sound_consum_86 ,
49+ sound_infinity_86 ,
50+ sound_open_parchemin ,
51+ sound_level_up ,
52+ sound_ninho ,
53+ NULL
54+ };
4655
4756static int init_win_component_sound (window_t * win , scene_t * scene ,
4857 const char * key_to_get , const char * path_to_data )
@@ -63,15 +72,10 @@ static int init_win_component_sound(window_t *win, scene_t *scene,
6372
6473int init_sounds (scene_t * scene , window_t * win )
6574{
66-
67- init_win_component_sound (win , scene , HURTED_SOUND , sound_hited_path );
68- init_win_component_sound (win , scene , HURT_SOUNG , sound_hit_path );
69- init_win_component_sound (win , scene , OPEN_INV_SOUND , sound_open_fridge );
70- init_win_component_sound (win , scene , CLOSE_INV_SOUND , sound_close_fridge );
71- init_win_component_sound (win , scene , CONSUM_CAN_SOUND , sound_consum_86 );
72- init_win_component_sound (win , scene , INFINITY_86_SOUND , sound_infinity_86 );
73- init_win_component_sound (win , scene , PARCHEMIN_SOUND , sound_open_parchemin );
74- init_win_component_sound (win , scene , LEVEL_UP_SOUND , sound_level_up );
75- init_win_component_music (win , scene , MUSIC_GAME , music_in_game );
75+ for (int i = 0 ; keys_to_get [i ] != NULL ||
76+ paths_to_data_sound [i ] != NULL ; i ++ ) {
77+ init_win_component_sound (win , scene , keys_to_get [i ],
78+ paths_to_data_sound [i ]);
79+ }
7680 return RET_OK ;
7781}
0 commit comments