Update asteroidWithDangerousAlien.c

parent 1467bccd
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
#define PLAYER_SPEED 6.0f #define PLAYER_SPEED 6.0f
#define PLAYER_MAX_SHOOTS 10 #define PLAYER_MAX_SHOOTS 10
#define METEORS_SPEED 2 #define METEORS_SPEED 3
#define MAX_BIG_METEORS 4 #define MAX_BIG_METEORS 3
#define MAX_MEDIUM_METEORS 6 #define MAX_MEDIUM_METEORS 8
#define MAX_SMALL_METEORS 16 #define MAX_SMALL_METEORS 14
#define MAX_SUIVEURS 40 #define MAX_SUIVEURS 50
#define MIN_SPEED_SUIVEURS 3.0f #define MIN_SPEED_SUIVEURS 3.0f
#define MAX_SPEED_SUIVEURS 10.0f #define MAX_SPEED_SUIVEURS 10.0f
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
...@@ -117,7 +117,7 @@ int main(void) ...@@ -117,7 +117,7 @@ int main(void)
{ {
// Initialization (Note windowTitle is unused on Android) // Initialization (Note windowTitle is unused on Android)
//--------------------------------------------------------- //---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "sample game: FlockThis"); InitWindow(screenWidth, screenHeight, "asteroid");
InitGame(); InitGame();
...@@ -343,32 +343,10 @@ Vector2 regle2(Suiveur suiveur) { ...@@ -343,32 +343,10 @@ Vector2 regle2(Suiveur suiveur) {
return repulsionForce; 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) // Update game (one frame)
void UpdateGame(void) void UpdateGame(void)
{ {
if (!gameOver) if (!gameOver && !victory)
{ {
if (IsKeyPressed('P')) pause = !pause; if (IsKeyPressed('P')) pause = !pause;
...@@ -669,7 +647,7 @@ void DrawGame(void) ...@@ -669,7 +647,7 @@ void DrawGame(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
if (!gameOver) if (!gameOver && !victory)
{ {
// Draw spaceship // Draw spaceship
Vector2 v1 = { player.position.x + sinf(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cosf(player.rotation*DEG2RAD)*(shipHeight) }; 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) ...@@ -679,10 +657,6 @@ void DrawGame(void)
// Draw suiveurs // Draw suiveurs
for(int i = 0; i < MAX_SUIVEURS; i++) { 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); DrawCircleV(suiveurs[i].position, suiveurs[i].radius, suiveurs[i].color);
} }
...@@ -711,10 +685,16 @@ void DrawGame(void) ...@@ -711,10 +685,16 @@ void DrawGame(void)
if (shoot[i].active) DrawCircleV(shoot[i].position, shoot[i].radius, BLACK); 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); 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); else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
EndDrawing(); EndDrawing();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment