Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
methodo2022-ispi-tp-1.2-shcherba-osadtsiv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SHCHERBA Denys
methodo2022-ispi-tp-1.2-shcherba-osadtsiv
Commits
661ababf
Commit
661ababf
authored
2 years ago
by
Denys
Browse files
Options
Downloads
Patches
Plain Diff
added functions working with music, updated documentation
parent
11b358ab
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
project/main.c
+30
-20
30 additions, 20 deletions
project/main.c
project/space_graphics.h
+5
-5
5 additions, 5 deletions
project/space_graphics.h
project/space_logics.c
+0
-1
0 additions, 1 deletion
project/space_logics.c
project/test.c
+4
-0
4 additions, 0 deletions
project/test.c
with
39 additions
and
26 deletions
project/main.c
+
30
−
20
View file @
661ababf
...
...
@@ -2,7 +2,7 @@
/// @brief Main file responsible for game functionality
/// @author Mathieu Constant, Denys SHCHERBA, Ivan OSADTSIV
/// @version 1.0
/// @date 1
0
.0
4
.2023
/// @date 1
7
.0
5
.2023
#include
"sdl2-light.h"
...
...
@@ -97,13 +97,27 @@ void init_walls(world_t * world)
}
/// @brief initialisation de music
/// @param bgmsc background music
void
init_music
(
Mix_Music
*
bgmsc
)
{
SDL_Init
(
SDL_INIT_VIDEO
|
SDL_INIT_AUDIO
);
Mix_Init
(
MIX_INIT_MP3
|
MIX_INIT_OGG
);
Mix_OpenAudio
(
44100
,
MIX_DEFAULT_FORMAT
,
6
,
4096
);
bgmsc
=
Mix_LoadMUS
(
"ressources/music/music_1.wav"
);
Mix_PlayMusic
(
bgmsc
,
0
);
}
/// @brief fonction qui initialise le jeu: initialisation de la partie graphique (SDL), chargement des textures, initialisation des données
/// @param window la fenêtre du jeu
/// @param renderer le renderer
/// @param textures les textures
/// @param world le monde
void
init
(
SDL_Window
**
window
,
SDL_Renderer
**
renderer
,
resources_t
*
textures
,
world_t
*
world
)
/// @param bgmsc background music
void
init
(
SDL_Window
**
window
,
SDL_Renderer
**
renderer
,
resources_t
*
textures
,
world_t
*
world
,
Mix_Music
*
bgmsc
)
{
init_music
(
bgmsc
);
init_sdl
(
window
,
renderer
,
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
init_data
(
world
);
init_ttf
();
...
...
@@ -113,26 +127,30 @@ void init(SDL_Window **window, SDL_Renderer ** renderer, resources_t *textures,
}
/// @brief close an open music file
/// @param bgmsc background music
void
clean_music
(
Mix_Music
*
bgmsc
)
{
Mix_FreeMusic
(
bgmsc
);
Mix_CloseAudio
();
Mix_HaltMusic
();
Mix_Quit
();
}
/// @brief programme principal qui implémente la boucle du jeu
int
main
(
int
argc
,
char
*
args
[]
)
{
SDL_Init
(
SDL_INIT_VIDEO
|
SDL_INIT_AUDIO
);
Mix_Init
(
MIX_INIT_MP3
|
MIX_INIT_OGG
);
Mix_OpenAudio
(
44100
,
MIX_DEFAULT_FORMAT
,
6
,
4096
);
Mix_Music
*
bgmsc
=
Mix_LoadMUS
(
"ressources/music/music_1.wav"
);
Mix_PlayMusic
(
bgmsc
,
0
);
SDL_Event
event
;
world_t
world
;
resources_t
textures
;
SDL_Renderer
*
renderer
;
SDL_Window
*
window
;
Mix_Music
*
bgmsc
;
//initialisation du jeu
init
(
&
window
,
&
renderer
,
&
textures
,
&
world
);
Mix_PlayMusic
(
bgmsc
,
0
);
init
(
&
window
,
&
renderer
,
&
textures
,
&
world
,
bgmsc
);
while
(
!
is_game_over
(
&
world
)){
//tant que le jeu n'est pas fini
//gestion des évènements
...
...
@@ -151,14 +169,6 @@ int main( int argc, char* args[] )
//nettoyage final
clean
(
window
,
renderer
,
&
textures
,
&
world
);
if
(
Mix_PlayMusic
(
bgmsc
,
-
1
)
==-
1
)
{
printf
(
"Mix_PlayMusic: %s
\n
"
,
Mix_GetError
());
// well, there's no music, but most games don't break without music...
}
Mix_FreeMusic
(
bgmsc
);
Mix_CloseAudio
();
Mix_HaltMusic
();
Mix_Quit
();
clean_music
(
bgmsc
);
return
0
;
}
This diff is collapsed.
Click to expand it.
project/space_graphics.h
+
5
−
5
View file @
661ababf
/// @file space_graphics.h
/// @author SHCHERBA Denys, OSADTSIV Ivan
/// @brief File with
classes and
methods responsible for game graphics
/// @brief File with methods responsible for game graphics
#include
"sdl2-light.h"
#include
"space_logics.h"
...
...
@@ -41,10 +41,10 @@ void apply_sprite(SDL_Renderer *renderer, SDL_Texture *texture, sprite_t *sprite
/// @param sprite sprite to apply
void
apply_wall
(
SDL_Renderer
*
renderer
,
SDL_Texture
*
texture
,
sprite_t
*
sprite
);
/// @brief
no
/// @param renderer
no
/// @param texture
no
/// @param sprite
no
/// @brief
Applies all the walls
/// @param renderer
renderer
/// @param texture
texture
/// @param sprite
sprite to apply
void
apply_walls
(
SDL_Renderer
*
renderer
,
SDL_Texture
*
texture
,
world_t
*
world
);
...
...
This diff is collapsed.
Click to expand it.
project/space_logics.c
+
0
−
1
View file @
661ababf
...
...
@@ -5,7 +5,6 @@
#include
"space_logics.h"
#include
"space_const.h"
#include
"space_graphics.h"
#include
"sdl2-light.h"
int
is_game_over
(
world_t
*
world
)
...
...
This diff is collapsed.
Click to expand it.
project/test.c
+
4
−
0
View file @
661ababf
/// @file test.c
/// @author SHCHERBA Denys, OSADTSIV Ivan
/// @brief file to test some important mechanics
#include
"sdl2-light.h"
#include
<stdio.h>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment