Commit d7f7fb2e authored by Lila NICKLER's avatar Lila NICKLER

Ajout d'ennemies de differentes taille avec des niveau de vie

parent 391cbfe6
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#define NUM_SHOOTS 50 #define NUM_SHOOTS 50
#define NUM_MAX_ENEMIES 50 #define NUM_MAX_ENEMIES 50
#define FIRST_WAVE 10 #define FIRST_WAVE 10
#define SECOND_WAVE 20 #define SECOND_WAVE 10
#define THIRD_WAVE 50 #define THIRD_WAVE 20
#define FOURTH_WAVE 100 #define FOURTH_WAVE 1
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
...@@ -43,6 +43,8 @@ typedef struct Enemy{ ...@@ -43,6 +43,8 @@ typedef struct Enemy{
Vector2 speed; Vector2 speed;
bool active; bool active;
Color color; Color color;
bool boss;
int life;
} Enemy; } Enemy;
typedef struct Shoot{ typedef struct Shoot{
...@@ -52,12 +54,6 @@ typedef struct Shoot{ ...@@ -52,12 +54,6 @@ typedef struct Shoot{
Color color; Color color;
} Shoot; } Shoot;
typedef struct Boss{
Rectangle rec;
Vector2 speed;
bool active ;
Color color;
} Boss;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
...@@ -75,7 +71,6 @@ static Player player = { 0 }; ...@@ -75,7 +71,6 @@ static Player player = { 0 };
static Enemy enemy[NUM_MAX_ENEMIES] = { 0 }; static Enemy enemy[NUM_MAX_ENEMIES] = { 0 };
static Shoot shoot[NUM_SHOOTS] = { 0 }; static Shoot shoot[NUM_SHOOTS] = { 0 };
static EnemyWave wave = { 0 }; static EnemyWave wave = { 0 };
static Boss boss = { 0 };
static int shootRate = 0; static int shootRate = 0;
...@@ -169,16 +164,10 @@ void InitGame(void) ...@@ -169,16 +164,10 @@ void InitGame(void)
enemy[i].speed.y = 5; enemy[i].speed.y = 5;
enemy[i].active = true; enemy[i].active = true;
enemy[i].color = GRAY; enemy[i].color = GRAY;
enemy[i].boss = false;
enemy[i].life = 0;
} }
//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 // Initialize shoots
for (int i = 0; i < NUM_SHOOTS; i++) for (int i = 0; i < NUM_SHOOTS; i++)
...@@ -248,7 +237,17 @@ void UpdateGame(void) ...@@ -248,7 +237,17 @@ void UpdateGame(void)
for (int i = 0; i < activeEnemies; i++) for (int i = 0; i < activeEnemies; i++)
{ {
if (!enemy[i].active) enemy[i].active = true; enemy[i].active= true;
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 = false;
enemy[i].life = 10;
} }
activeEnemies = THIRD_WAVE; activeEnemies = THIRD_WAVE;
...@@ -272,6 +271,21 @@ void UpdateGame(void) ...@@ -272,6 +271,21 @@ void UpdateGame(void)
{ {
enemiesKill = 0; enemiesKill = 0;
for (int i = 0; i < activeEnemies; i++)
{
//Initiliaze the boss
enemy[i].active= true;
enemy[i].rec.width =200;
enemy[i].rec.height = 400;
enemy[i].rec.x = screenWidth;
enemy[i].rec.y = screenHeight/2;
enemy[i].speed.x = 1;
enemy[i].speed.y = 1;
enemy[i].active = true;
enemy[i].color = BLACK;
enemy[i].boss = true;
enemy[i].life = 100;
}
for (int i = 0; i < activeEnemies; i++) for (int i = 0; i < activeEnemies; i++)
{ {
if (!enemy[i].active) enemy[i].active = true; if (!enemy[i].active) enemy[i].active = true;
...@@ -321,9 +335,15 @@ void UpdateGame(void) ...@@ -321,9 +335,15 @@ void UpdateGame(void)
if (enemy[i].rec.x < 0) if (enemy[i].rec.x < 0)
{ {
if (!enemy[i].boss){
enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height); enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
} }
}
} }
} }
...@@ -355,6 +375,7 @@ void UpdateGame(void) ...@@ -355,6 +375,7 @@ void UpdateGame(void)
{ {
if (shoot[i].active) if (shoot[i].active)
{ {
// Movement // Movement
shoot[i].rec.x += shoot[i].speed.x; shoot[i].rec.x += shoot[i].speed.x;
...@@ -363,7 +384,8 @@ void UpdateGame(void) ...@@ -363,7 +384,8 @@ void UpdateGame(void)
{ {
if (enemy[j].active) if (enemy[j].active)
{ {
if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec)) if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec)){
if (enemy[j].life == 0)
{ {
shoot[i].active = false; shoot[i].active = false;
enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000); enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
...@@ -371,6 +393,13 @@ void UpdateGame(void) ...@@ -371,6 +393,13 @@ void UpdateGame(void)
shootRate = 0; shootRate = 0;
enemiesKill++; enemiesKill++;
score += 100; score += 100;
}else {
shoot[i].active = false;
shootRate = 0;
enemy[j].life--;
score +=100;
}
} }
if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth) if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth)
......
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