Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SpaceInvaders_upgrade
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
Lila NICKLER
SpaceInvaders_upgrade
Commits
933ba8b1
Commit
933ba8b1
authored
Oct 30, 2020
by
Lila NICKLER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout du score a la fin + highscore sauvgardé
parent
d3d56a45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
space_invaders.c
space_invaders.c
+26
-6
No files found.
space_invaders.c
View file @
933ba8b1
...
...
@@ -79,6 +79,7 @@ static bool gameOver = false;
static
bool
pause
=
false
;
static
int
score
=
0
;
static
bool
victory
=
false
;
static
int
highscore
;
static
Player
player
=
{
0
};
static
Enemy
enemy
[
NUM_MAX_ENEMIES
]
=
{
0
};
...
...
@@ -157,6 +158,7 @@ void InitGame(void)
enemiesKill
=
0
;
score
=
0
;
alpha
=
0
;
highscore
=
LoadStorageValue
(
0
);
// Initialize player
player
.
rec
.
x
=
20
;
...
...
@@ -367,7 +369,19 @@ void UpdateGame(void)
}
if
(
smooth
)
alpha
-=
0
.
02
f
;
if
(
enemy
[
0
].
life
==
0
)
victory
=
true
;
if
(
enemy
[
0
].
life
==
0
){
victory
=
true
;
if
(
score
>
highscore
)
{
highscore
=
score
;
SaveStorageValue
(
0
,
highscore
);
gameOver
=
true
;
}
}
}
...
...
@@ -447,7 +461,6 @@ void UpdateGame(void)
break
;
default:
break
;
}
}
}
...
...
@@ -612,11 +625,18 @@ void DrawGame(void)
DrawText
(
"Life:"
,
20
,
40
,
30
,
GRAY
);
DrawText
(
TextFormat
(
"%i"
,
player
.
life
),
100
,
40
,
30
,
RED
);
if
(
victory
)
DrawText
(
"YOU WIN"
,
screenWidth
/
2
-
MeasureText
(
"YOU WIN"
,
40
)
/
2
,
screenHeight
/
2
-
40
,
40
,
BLACK
);
if
(
pause
)
DrawText
(
"GAME PAUSED"
,
screenWidth
/
2
-
MeasureText
(
"GAME PAUSED"
,
40
)
/
2
,
screenHeight
/
2
-
40
,
40
,
GRAY
);
if
(
pause
){
DrawText
(
"GAME PAUSED"
,
screenWidth
/
2
-
MeasureText
(
"GAME PAUSED"
,
40
)
/
2
,
screenHeight
/
3
-
40
,
40
,
GRAY
);
DrawText
(
"SCORE"
,
screenWidth
/
2
-
MeasureText
(
"GAME PAUSED"
,
40
)
/
2
,
2
*
screenHeight
/
3
,
40
,
BLACK
);
DrawText
(
TextFormat
(
"%04i"
,
score
),
screenWidth
/
2
+
MeasureText
(
"SCORE:"
,
40
)
/
2
,
2
*
screenHeight
/
3
,
40
,
RED
);
}
}
else
if
(
victory
)
{
DrawText
(
"YOU WIN"
,
screenWidth
/
2
-
MeasureText
(
"YOU WIN"
,
40
)
/
2
,
screenHeight
/
4
-
40
,
40
,
BLACK
);
DrawText
(
TextFormat
(
"SCORE:%04i"
,
score
),
screenWidth
/
2
-
MeasureText
(
"SCORE:%04i"
,
40
)
/
2
,
2
*
screenHeight
/
4
,
40
,
BLACK
);
DrawText
(
TextFormat
(
"HIGHSCORE:%04i"
,
highscore
),
screenWidth
/
2
-
MeasureText
(
"HIGHSCORE:%04i"
,
40
)
/
2
,
3
*
screenHeight
/
4
,
40
,
RED
);
}
else
DrawText
(
"PRESS [ENTER] TO PLAY AGAIN"
,
GetScreenWidth
()
/
2
-
MeasureText
(
"PRESS [ENTER] TO PLAY AGAIN"
,
20
)
/
2
,
GetScreenHeight
()
/
2
-
50
,
20
,
GRAY
);
else
DrawText
(
"PRESS [ENTER] TO PLAY AGAIN"
,
GetScreenWidth
()
/
2
-
MeasureText
(
"PRESS [ENTER] TO PLAY AGAIN"
,
20
)
/
2
,
GetScreenHeight
()
/
2
-
50
,
20
,
GRAY
);
EndDrawing
();
...
...
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