Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SnakeProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Benjamin LEROUX
SnakeProject
Commits
61af3c7b
Commit
61af3c7b
authored
Oct 28, 2020
by
Benjamin LEROUX
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout bande son
parent
4ebd12c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
mini1111.xm
SnakeSounds/mini1111.xm
+0
-0
snake.c
snake.c
+18
-2
No files found.
SnakeSounds/mini1111.xm
0 → 100644
View file @
61af3c7b
File added
snake.c
View file @
61af3c7b
...
...
@@ -69,6 +69,9 @@ static int highscore;
static
Sound
fruitSound
;
static
Sound
goldenFruitSound
;
static
Sound
deathSound
;
static
Music
music
;
//------------------------------------------------------------------------------------
// Module Functions Declaration (local)
...
...
@@ -89,7 +92,11 @@ int main(void)
InitWindow
(
screenWidth
,
screenHeight
,
"sample game: snake"
);
InitGame
();
InitAudioDevice
();
// Initialize audio device
InitAudioDevice
();
// Initialize audio device
StopMusicStream
(
music
);
PlayMusicStream
(
music
);
#if defined(PLATFORM_WEB)
emscripten_set_main_loop
(
UpdateDrawFrame
,
0
,
1
);
...
...
@@ -150,6 +157,7 @@ void InitGame(void)
snakePosition
[
i
]
=
(
Vector2
){
0
.
0
f
,
0
.
0
f
};
}
//fruits
fruit
.
size
=
(
Vector2
){
SQUARE_SIZE
,
SQUARE_SIZE
};
fruit
.
color
=
GREEN
;
fruit
.
active
=
false
;
...
...
@@ -162,6 +170,7 @@ void InitGame(void)
deadFruit
.
color
=
BLACK
;
deadFruit
.
active
=
false
;
//murs
recTab
[
0
].
x
=
2
*
SQUARE_SIZE
+
offset
.
x
/
2
;
//mur haut gauche
recTab
[
0
].
y
=
2
*
SQUARE_SIZE
+
offset
.
y
/
2
;
recTab
[
0
].
width
=
(
SQUARE_SIZE
)
-
0
.
1
;
...
...
@@ -204,9 +213,11 @@ void InitGame(void)
highscore
=
LoadStorageValue
(
0
);
//sons
fruitSound
=
LoadSound
(
"SnakeSounds
\\
coin.wav"
);
// Load audio files
goldenFruitSound
=
LoadSound
(
"SnakeSounds
\\
sound.wav"
);
deathSound
=
LoadSound
(
"SnakeSounds
\\
tanatana.ogg"
);
deathSound
=
LoadSound
(
"SnakeSounds
\\
tanatana.ogg"
);
music
=
LoadMusicStream
(
"SnakeSounds
\\
mini1111.xm"
);
}
void
drawWalls
(){
...
...
@@ -245,6 +256,8 @@ void UpdateGame(void)
if
(
!
pause
)
{
UpdateMusicStream
(
music
);
// Player control
if
(
IsKeyPressed
(
KEY_RIGHT
)
&&
(
snake
[
0
].
speed
.
x
==
0
)
&&
allowMove
)
{
...
...
@@ -400,6 +413,8 @@ void UpdateGame(void)
if
(
IsKeyPressed
(
KEY_ENTER
))
{
InitGame
();
StopMusicStream
(
music
);
PlayMusicStream
(
music
);
gameOver
=
false
;
}
}
...
...
@@ -467,6 +482,7 @@ void UnloadGame(void)
UnloadSound
(
fruitSound
);
UnloadSound
(
goldenFruitSound
);
UnloadSound
(
deathSound
);
CloseAudioDevice
();
}
// Update and Draw (one frame)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment