-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Dev #192
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0c1e461
Modif architecture of audio
KitetsuK 5570247
Add new sound
KitetsuK 32da4c5
Add new sound
KitetsuK e91ae49
Modif sound to make the format able to open
KitetsuK 61b68f5
Add update function for ninho npc
KitetsuK c074b76
Fix norm
KitetsuK 9d46d52
Fix norm
KitetsuK 82a3c84
Merge pull request #191 from X-R-G-B/ninho_sound
Saverio976 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| ** EPITECH PROJECT, 2022 | ||
| ** B-MUL-200-TLS-2-1-myrpg-xavier.mitault | ||
| ** File description: | ||
| ** init_music | ||
| */ | ||
|
|
||
| #include "my_rpg.h" | ||
| #include "my_bgs_components.h" | ||
| #include "audio.h" | ||
| #include "macro.h" | ||
|
|
||
| extern const int layer; | ||
|
|
||
| static const char music_in_game[] = | ||
| "./assets/music/game_music.ogg"; | ||
| const char MUSIC_GAME[] = "musicgame"; | ||
|
|
||
| static const char *keys_to_get[] = { | ||
| MUSIC_GAME, NULL | ||
| }; | ||
|
|
||
| static const char *paths_to_data_sound[] = { | ||
| music_in_game, NULL | ||
| }; | ||
|
|
||
| static int init_win_component_music(window_t *win, scene_t *scene, | ||
| const char *key_to_get, const char *path_to_data) | ||
| { | ||
| object_t *obj = NULL; | ||
|
|
||
| if (scene == NULL || win == NULL) { | ||
| return RET_ERR_INPUT; | ||
| } | ||
| obj = create_object(NULL, NULL, scene, layer); | ||
| if (object_set_audio(obj, path_to_data, false, false) != BGS_OK) { | ||
| return RET_ERR_MALLOC; | ||
| } | ||
| add_new_audio(obj, win); | ||
| window_add_component(win, obj, key_to_get, NULL); | ||
| return RET_OK; | ||
| } | ||
|
|
||
| int init_music_game(window_t *win, scene_t *scene) | ||
| { | ||
| for (int i = 0; keys_to_get[i] != NULL || | ||
| paths_to_data_sound[i] != NULL; i++) { | ||
| init_win_component_music(win, scene, keys_to_get[i], | ||
| paths_to_data_sound[i]); | ||
| } | ||
| return RET_OK; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| ** EPITECH PROJECT, 2022 | ||
| ** FlashBackToTheFuture | ||
| ** File description: | ||
| ** update_ninho | ||
| */ | ||
|
|
||
| #include "npc.h" | ||
| #include "my_rpg.h" | ||
| #include "macro.h" | ||
| #include "stage.h" | ||
| #include "player.h" | ||
| #include "audio.h" | ||
|
|
||
| extern const char npc_path_key[]; | ||
|
|
||
| static const sfKeyCode key_interract = sfKeyE; | ||
|
|
||
| static void check_next_stage_event(object_t *obj, window_t *win, | ||
| __attribute__((unused)) scene_t *scene) | ||
| { | ||
| player_t *player = dico_t_get_value(win->components, PLAYER); | ||
| sfFloatRect player_rect = {0}; | ||
| sfFloatRect npc_rect = sfSprite_getGlobalBounds(obj->drawable.sprite); | ||
|
|
||
| if (player == NULL) { | ||
| return; | ||
| } | ||
| player_rect = sfSprite_getGlobalBounds(player->obj->drawable.sprite); | ||
| if (sfFloatRect_intersects(&player_rect, &npc_rect, NULL) == sfTrue && | ||
| sfKeyboard_isKeyPressed(key_interract) == sfTrue) { | ||
| play_sound(win, NINHO); | ||
| } | ||
| } | ||
|
|
||
| static void ninho_npc_update(object_t *obj, scene_t *scene, window_t *win, | ||
| float dtime) | ||
| { | ||
| check_next_stage_event(obj, win, scene); | ||
| update_npc(obj, scene, win, dtime); | ||
| } | ||
|
|
||
| void update_ninho(object_t *obj, scene_t *scene, window_t *win, | ||
| __attribute__((unused)) float dtime) | ||
| { | ||
| char *npc_path = NULL; | ||
| object_t *npc = NULL; | ||
|
|
||
| if (obj == NULL || obj->components == NULL || | ||
| scene == NULL || win == NULL) { | ||
| return; | ||
| } | ||
| npc_path = dico_t_get_value(obj->components, npc_path_key); | ||
| if (npc_path == NULL) { | ||
| return; | ||
| } | ||
| npc = add_npc(scene, npc_path, obj->bigdata.sprite_bigdata.pos, | ||
| &callback_npc); | ||
| npc->update = &ninho_npc_update; | ||
| obj->components = dico_t_rem(obj->components, npc_path_key); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check key_to_get and path_to_data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nik toi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrige ton code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xavier t pas cool