Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Mini-Projet-TETRIS
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
DIDON Maya
Mini-Projet-TETRIS
Commits
96275e65
Commit
96275e65
authored
Oct 31, 2020
by
DIDON Maya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout d'une grille de couleur
parent
b0272bc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
high-score.txt
high-score.txt
+1
-1
tetris.c
tetris.c
+29
-8
tetris.exe
tetris.exe
+0
-0
No files found.
high-score.txt
View file @
96275e65
63443
\ No newline at end of file
1473379
\ No newline at end of file
tetris.c
View file @
96275e65
...
...
@@ -106,13 +106,13 @@ static void CheckDetection();
static
void
CheckCompletion
();
static
int
DeleteCompleteLines
();
static
unsigned
int
ReadHighScore
();
static
Color
GiveLinesColors
(
int
);
// High score variable
static
int
highScore
=
0
;
// Music variables
// Music
and sound
variables
Music
soundtrack
;
Sound
losing
;
Sound
fading
;
//------------------------------------------------------------------------------------
...
...
@@ -128,10 +128,8 @@ int main(void)
InitAudioDevice
();
char
*
music
=
"tetris-soundtrack.mp3"
;
char
*
fade
=
"fading-sound.mp3"
;
char
*
lose
=
"losing-sound.mp3"
;
soundtrack
=
LoadMusicStream
(
music
);
fading
=
LoadSound
(
fade
);
losing
=
LoadSound
(
lose
);
PlayMusicStream
(
soundtrack
);
InitGame
();
...
...
@@ -329,12 +327,10 @@ void UpdateGame(void)
else
{
StopMusicStream
(
soundtrack
);
PlaySound
(
losing
);
if
(
IsKeyPressed
(
KEY_ENTER
))
{
InitGame
();
gameOver
=
false
;
StopSound
(
losing
);
PlayMusicStream
(
soundtrack
);
}
}
...
...
@@ -373,7 +369,7 @@ void DrawGame(void)
}
else
if
(
grid
[
i
][
j
]
==
FULL
)
{
DrawRectangle
(
offset
.
x
,
offset
.
y
,
SQUARE_SIZE
,
SQUARE_SIZE
,
G
RAY
);
DrawRectangle
(
offset
.
x
,
offset
.
y
,
SQUARE_SIZE
,
SQUARE_SIZE
,
G
iveLinesColors
(
j
)
);
offset
.
x
+=
SQUARE_SIZE
;
}
else
if
(
grid
[
i
][
j
]
==
MOVING
)
...
...
@@ -446,7 +442,6 @@ void UnloadGame(void)
{
UnloadMusicStream
(
soundtrack
);
UnloadSound
(
fading
);
UnloadSound
(
losing
);
}
// Update and Draw (one frame)
...
...
@@ -852,4 +847,30 @@ static unsigned int ReadHighScore(){
fscanf
(
dataFile
,
"%u"
,
&
highScore
);
fclose
(
dataFile
);
return
(
highScore
);
}
// Allocates colors to differents lines
static
Color
GiveLinesColors
(
int
i
){
switch
(
i
){
case
18
:
return
(
PINK
);
break
;
case
17
:
return
(
RED
);
break
;
case
16
:
return
(
ORANGE
);
break
;
case
15
:
return
(
GOLD
);
break
;
case
14
:
return
(
YELLOW
);
break
;
case
13
:
return
(
GREEN
);
break
;
case
12
:
return
(
LIME
);
break
;
case
11
:
return
(
DARKGREEN
);
break
;
case
10
:
return
(
DARKBLUE
);
break
;
case
9
:
return
(
BLUE
);
break
;
case
8
:
return
(
SKYBLUE
);
break
;
case
7
:
return
(
PURPLE
);
break
;
case
6
:
return
(
VIOLET
);
break
;
case
5
:
return
(
DARKPURPLE
);
break
;
case
4
:
return
(
BROWN
);
break
;
case
3
:
return
(
BROWN
);
break
;
case
2
:
return
(
DARKBROWN
);
break
;
case
1
:
return
(
BLACK
);
break
;
case
0
:
return
(
BLACK
);
break
;
default
:
return
(
WHITE
);
}
}
\ No newline at end of file
tetris.exe
View file @
96275e65
No preview for this file type
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