Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini projet
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
LE TENOUX--RACHIDI Isham
mini projet
Commits
78725a54
Commit
78725a54
authored
Nov 02, 2020
by
LE TENOUX--RACHIDI Isham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update asteroidWithDangerousAlien.c
parent
1467bccd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
36 deletions
+16
-36
asteroidWithDangerousAlien.c
asteroidWithDangerousAlien.c
+16
-36
No files found.
asteroidWithDangerousAlien.c
View file @
78725a54
...
...
@@ -28,11 +28,11 @@
#define PLAYER_SPEED 6.0f
#define PLAYER_MAX_SHOOTS 10
#define METEORS_SPEED
2
#define MAX_BIG_METEORS
4
#define MAX_MEDIUM_METEORS
6
#define MAX_SMALL_METEORS 1
6
#define MAX_SUIVEURS
4
0
#define METEORS_SPEED
3
#define MAX_BIG_METEORS
3
#define MAX_MEDIUM_METEORS
8
#define MAX_SMALL_METEORS 1
4
#define MAX_SUIVEURS
5
0
#define MIN_SPEED_SUIVEURS 3.0f
#define MAX_SPEED_SUIVEURS 10.0f
//----------------------------------------------------------------------------------
...
...
@@ -117,7 +117,7 @@ int main(void)
{
// Initialization (Note windowTitle is unused on Android)
//---------------------------------------------------------
InitWindow
(
screenWidth
,
screenHeight
,
"
sample game: FlockThis
"
);
InitWindow
(
screenWidth
,
screenHeight
,
"
asteroid
"
);
InitGame
();
...
...
@@ -343,32 +343,10 @@ Vector2 regle2(Suiveur suiveur) {
return
repulsionForce
;
}
float
orientationMoyenne
(
Suiveur
suiveur
)
{
//uniformisation de l'orientation des suiveurs
float
rotationMoyenne
=
0
;
for
(
int
i
=
0
;
i
<
MAX_SUIVEURS
;
i
++
)
{
if
(
notEqual
(
suiveurs
[
i
],
suiveur
))
{
rotationMoyenne
+=
suiveurs
[
i
].
rotation
;
}
}
rotationMoyenne
+=
player
.
rotation
;
rotationMoyenne
/=
MAX_SUIVEURS
;
return
rotationMoyenne
;
}
float
orientationAvecDirection
(
Suiveur
suiveur
)
{
float
angle
=
0
;
angle
=
atan
(
suiveur
.
speed
.
y
/
suiveur
.
speed
.
x
);
return
angle
*
(
180
.
0
/
PI
);
}
// Update game (one frame)
void
UpdateGame
(
void
)
{
if
(
!
gameOver
)
if
(
!
gameOver
&&
!
victory
)
{
if
(
IsKeyPressed
(
'P'
))
pause
=
!
pause
;
...
...
@@ -669,7 +647,7 @@ void DrawGame(void)
ClearBackground
(
RAYWHITE
);
if
(
!
gameOver
)
if
(
!
gameOver
&&
!
victory
)
{
// Draw spaceship
Vector2
v1
=
{
player
.
position
.
x
+
sinf
(
player
.
rotation
*
DEG2RAD
)
*
(
shipHeight
),
player
.
position
.
y
-
cosf
(
player
.
rotation
*
DEG2RAD
)
*
(
shipHeight
)
};
...
...
@@ -679,10 +657,6 @@ void DrawGame(void)
// Draw suiveurs
for
(
int
i
=
0
;
i
<
MAX_SUIVEURS
;
i
++
)
{
/*Vector2 v1 = { suiveurs[i].position.x + sinf(suiveurs[i].rotation*DEG2RAD)*(shipHeight), suiveurs[i].position.y - cosf(suiveurs[i].rotation*DEG2RAD)*(shipHeight) };
Vector2 v2 = { suiveurs[i].position.x - cosf(suiveurs[i].rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), suiveurs[i].position.y - sinf(suiveurs[i].rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) };
Vector2 v3 = { suiveurs[i].position.x + cosf(suiveurs[i].rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), suiveurs[i].position.y + sinf(suiveurs[i].rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) };
DrawTriangle(v1, v2, v3, suiveurs[i].color);*/
DrawCircleV
(
suiveurs
[
i
].
position
,
suiveurs
[
i
].
radius
,
suiveurs
[
i
].
color
);
}
...
...
@@ -711,10 +685,16 @@ void DrawGame(void)
if
(
shoot
[
i
].
active
)
DrawCircleV
(
shoot
[
i
].
position
,
shoot
[
i
].
radius
,
BLACK
);
}
if
(
victory
)
DrawText
(
"VICTORY"
,
screenWidth
/
2
-
MeasureText
(
"VICTORY"
,
20
)
/
2
,
screenHeight
/
2
,
20
,
LIGHTGRAY
);
DrawText
(
TextFormat
(
"Destroyed Meteors: %02i"
,
destroyedMeteorsCount
),
screenWidth
-
300
,
100
,
14
,
BLACK
);
DrawText
(
TextFormat
(
"Total Meteors: %02i"
,
MAX_BIG_METEORS
+
MAX_MEDIUM_METEORS
+
MAX_SMALL_METEORS
),
screenWidth
-
300
,
120
,
14
,
BLACK
);
if
(
pause
)
DrawText
(
"GAME PAUSED"
,
screenWidth
/
2
-
MeasureText
(
"GAME PAUSED"
,
40
)
/
2
,
screenHeight
/
2
-
40
,
40
,
GRAY
);
}
else
if
(
victory
)
{
ClearBackground
(
RAYWHITE
);
DrawText
(
"VICTORY"
,
screenWidth
/
2
-
MeasureText
(
"VICTORY"
,
20
)
/
2
,
screenHeight
/
2
,
20
,
LIGHTGRAY
);
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