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 @@
#define NUM_SHOOTS 50
#define NUM_MAX_ENEMIES 50
#define FIRST_WAVE 10
#define SECOND_WAVE 20
#define THIRD_WAVE 50
#define FOURTH_WAVE 100
#define SECOND_WAVE 10
#define THIRD_WAVE 20
#define FOURTH_WAVE 1
//----------------------------------------------------------------------------------
// Types and Structures Definition
......@@ -43,6 +43,8 @@ typedef struct Enemy{
Vector2 speed;
bool active;
Color color;
bool boss;
int life;
} Enemy;
typedef struct Shoot{
......@@ -52,12 +54,6 @@ typedef struct Shoot{
Color color;
} Shoot;
typedef struct Boss{
Rectangle rec;
Vector2 speed;
bool active ;
Color color;
} Boss;
//------------------------------------------------------------------------------------
......@@ -75,7 +71,6 @@ 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;
......@@ -169,17 +164,11 @@ void InitGame(void)
enemy[i].speed.y = 5;
enemy[i].active = true;
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
for (int i = 0; i < NUM_SHOOTS; i++)
{
......@@ -246,9 +235,19 @@ void UpdateGame(void)
{
enemiesKill = 0;
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;
......@@ -272,6 +271,21 @@ void UpdateGame(void)
{
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++)
{
if (!enemy[i].active) enemy[i].active = true;
......@@ -286,13 +300,13 @@ void UpdateGame(void)
case FOURTH:
{
if (!smooth)
{
{
alpha += 0.02f;
if (alpha >= 1.0f) smooth = true;
}
if (smooth) alpha -= 0.02f;
if (enemiesKill == activeEnemies) victory = true;
}
......@@ -321,8 +335,14 @@ void UpdateGame(void)
if (enemy[i].rec.x < 0)
{
enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
if (!enemy[i].boss){
enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
}
}
}
}
......@@ -355,6 +375,7 @@ void UpdateGame(void)
{
if (shoot[i].active)
{
// Movement
shoot[i].rec.x += shoot[i].speed.x;
......@@ -363,14 +384,22 @@ void UpdateGame(void)
{
if (enemy[j].active)
{
if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec))
{
shoot[i].active = false;
enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[j].rec.y = GetRandomValue(0, screenHeight - enemy[j].rec.height);
shootRate = 0;
enemiesKill++;
score += 100;
if (CheckCollisionRecs(shoot[i].rec, enemy[j].rec)){
if (enemy[j].life == 0)
{
shoot[i].active = false;
enemy[j].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[j].rec.y = GetRandomValue(0, screenHeight - enemy[j].rec.height);
shootRate = 0;
enemiesKill++;
score += 100;
}else {
shoot[i].active = false;
shootRate = 0;
enemy[j].life--;
score +=100;
}
}
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