Commit 391cbfe6 authored by Lila NICKLER's avatar Lila NICKLER

Ajout d'une 4eme vague d'enemies + declaration du boss

parent d8727672
......@@ -25,11 +25,12 @@
#define FIRST_WAVE 10
#define SECOND_WAVE 20
#define THIRD_WAVE 50
#define FOURTH_WAVE 100
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef enum { FIRST = 0, SECOND, THIRD } EnemyWave;
typedef enum { FIRST = 0, SECOND, THIRD, FOURTH } EnemyWave;
typedef struct Player{
Rectangle rec;
......@@ -51,6 +52,14 @@ typedef struct Shoot{
Color color;
} Shoot;
typedef struct Boss{
Rectangle rec;
Vector2 speed;
bool active ;
Color color;
} Boss;
//------------------------------------------------------------------------------------
// Global Variables Declaration
//------------------------------------------------------------------------------------
......@@ -66,6 +75,8 @@ static Player player = { 0 };
static Enemy enemy[NUM_MAX_ENEMIES] = { 0 };
static Shoot shoot[NUM_SHOOTS] = { 0 };
static EnemyWave wave = { 0 };
static Boss boss = { 0 };
static int shootRate = 0;
static float alpha = 0.0f;
......@@ -160,6 +171,15 @@ void InitGame(void)
enemy[i].color = GRAY;
}
//Initialize boss
boss.rec.x = 50;
boss. rec.y = 50;
boss.rec.width = 20;
boss.rec.height = 20;
boss.speed.x = 2;
boss.speed.y= 2;
boss.color = GRAY;
// Initialize shoots
for (int i = 0; i < NUM_SHOOTS; i++)
{
......@@ -167,7 +187,7 @@ void InitGame(void)
shoot[i].rec.y = player.rec.y + player.rec.height/4;
shoot[i].rec.width = 10;
shoot[i].rec.height = 5;
shoot[i].speed.x = 7;
shoot[i].speed.x = 10;
shoot[i].speed.y = 0;
shoot[i].active = false;
shoot[i].color = MAROON;
......@@ -248,9 +268,35 @@ void UpdateGame(void)
if (smooth) alpha -= 0.02f;
if (enemiesKill == activeEnemies) victory = true;
if (enemiesKill == activeEnemies)
{
enemiesKill = 0;
for (int i = 0; i < activeEnemies; i++)
{
if (!enemy[i].active) enemy[i].active = true;
}
activeEnemies = FOURTH_WAVE;
wave = FOURTH;
smooth = false;
alpha = 0.0f;
}
} break;
case FOURTH:
{
if (!smooth)
{
alpha += 0.02f;
if (alpha >= 1.0f) smooth = true;
}
if (smooth) alpha -= 0.02f;
if (enemiesKill == activeEnemies) victory = true;
}
default: break;
}
......@@ -263,7 +309,7 @@ void UpdateGame(void)
// Player collision with enemy
for (int i = 0; i < activeEnemies; i++)
{
if (CheckCollisionRecs(player.rec, enemy[i].rec)) gameOver = true;
if (CheckCollisionRecs(player.rec, enemy[i].rec)) gameOver = false;
}
// Enemy behaviour
......@@ -362,6 +408,7 @@ 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));
for (int i = 0; i < activeEnemies; i++)
{
......
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