Commit 0efc18fc authored by Lila NICKLER's avatar Lila NICKLER

Affichage vie du joueur + meilleure affichage score + victoire si le boss est tué

parent da176a20
......@@ -25,7 +25,7 @@
#define FIRST_WAVE 10
#define SECOND_WAVE 10
#define THIRD_WAVE 20
#define FOURTH_WAVE 1
#define FOURTH_WAVE 20
//----------------------------------------------------------------------------------
// Types and Structures Definition
......@@ -36,6 +36,7 @@ typedef struct Player{
Rectangle rec;
Vector2 speed;
Color color;
int life;
} Player;
typedef struct Enemy{
......@@ -146,12 +147,13 @@ void InitGame(void)
// Initialize player
player.rec.x = 20;
player.rec.y = 50;
player.rec.y = 100;
player.rec.width = 20;
player.rec.height = 20;
player.speed.x = 5;
player.speed.y = 5;
player.color = BLACK;
player.life = 3;
// Initialize enemies
for (int i = 0; i < NUM_MAX_ENEMIES; i++)
......@@ -245,7 +247,7 @@ void UpdateGame(void)
enemy[i].speed.x = 5;
enemy[i].speed.y = 5;
enemy[i].active = true;
enemy[i].color = BLACK;
enemy[i].color = GRAY;
enemy[i].boss = false;
enemy[i].life = 10;
}
......@@ -270,21 +272,32 @@ void UpdateGame(void)
if (enemiesKill == activeEnemies)
{
enemiesKill = 0;
for (int i = 0; i < activeEnemies; i++)
{
//Initiliaze the boss
enemy[0].active= true;
enemy[0].rec.width =200;
enemy[0].rec.height = 700;
enemy[0].rec.x = screenWidth;
enemy[0].rec.y = 0;
enemy[0].speed.x = 1;
enemy[0].speed.y = 1;
enemy[0].active = true;
enemy[0].color = MAROON;
enemy[0].boss = true;
enemy[0].life = 100;
for (int i = 1; i < activeEnemies; i++)
{
enemy[i].active= true;
enemy[i].rec.width =200;
enemy[i].rec.height = 700;
enemy[i].rec.x = screenWidth;
enemy[i].rec.y = 0;
enemy[i].speed.x = 1;
enemy[i].speed.y = 1;
enemy[i].rec.width =50;
enemy[i].rec.height = 50;
enemy[i].rec.x = screenWidth/2;
enemy[i].rec.y = 200;
enemy[i].speed.x = 5;
enemy[i].speed.y = 5;
enemy[i].active = true;
enemy[i].color = BLACK;
enemy[i].boss = true;
enemy[i].life = 100;
enemy[i].color = GRAY;
enemy[i].boss = false;
enemy[i].life = 10;
}
for (int i = 0; i < activeEnemies; i++)
{
......@@ -307,7 +320,7 @@ void UpdateGame(void)
}
if (smooth) alpha -= 0.02f;
if (enemiesKill == activeEnemies) victory = true;
if (enemy[0].life == 0) victory = true;
}
......@@ -323,7 +336,16 @@ void UpdateGame(void)
// Player collision with enemy
for (int i = 0; i < activeEnemies; i++)
{
if (CheckCollisionRecs(player.rec, enemy[i].rec)) gameOver = false;
if (CheckCollisionRecs(player.rec, enemy[i].rec))
{
if (player.life == 1)
{
gameOver = false;
} else
{
player.life--;
}
}
}
// Enemy behaviour
......@@ -341,8 +363,6 @@ void UpdateGame(void)
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
}
}
}
}
......@@ -437,19 +457,27 @@ void DrawGame(void)
if (wave == FIRST) DrawText("FIRST WAVE", screenWidth/2 - MeasureText("FIRST WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == SECOND) DrawText("SECOND WAVE", screenWidth/2 - MeasureText("SECOND WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == THIRD) DrawText("THIRD WAVE", screenWidth/2 - MeasureText("THIRD WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == FOURTH) DrawText("FOURTH WAVE", screenWidth/2 - MeasureText("FOURTH WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == FOURTH)
{
DrawText("FOURTH WAVE:", screenWidth/2 - MeasureText("FOURTH WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
DrawText("BOSS IN COMMING", screenWidth/2 - MeasureText("BOSS IN COMMING", 40)/2, 2*screenHeight/3 - 40, 40, Fade(MAROON, alpha));
}
for (int i = 0; i < activeEnemies; i++)
{
if (enemy[i].active) DrawRectangleRec(enemy[i].rec, enemy[i].color);
}
}
for (int i = 0; i < NUM_SHOOTS; i++)
{
if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color);
}
DrawText(TextFormat("%04i", score), 20, 20, 40, GRAY);
DrawText("Score:",20,10,30, GRAY);
DrawText(TextFormat("%04i", score), 120, 10, 30, GRAY);
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);
......@@ -457,6 +485,7 @@ void DrawGame(void)
}
else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
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