Commit 70df5426 authored by Lila NICKLER's avatar Lila NICKLER

Resolution de pb sur l'item 3 bonus shoot

parent faf99d87
...@@ -92,6 +92,7 @@ static float alpha = 0.0f; ...@@ -92,6 +92,7 @@ static float alpha = 0.0f;
static int activeEnemies = 0; static int activeEnemies = 0;
static int enemiesKill = 0; static int enemiesKill = 0;
static bool smooth = false; static bool smooth = false;
static int ItemNumberWave= 1;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration (local) // Module Functions Declaration (local)
...@@ -222,7 +223,7 @@ void InitGame(void) ...@@ -222,7 +223,7 @@ void InitGame(void)
item[i].color = GRAY; item[i].color = GRAY;
break; break;
} }
item[i].active = false; item[i].active = true;
} }
...@@ -241,16 +242,11 @@ void UpdateGame(void) ...@@ -241,16 +242,11 @@ void UpdateGame(void)
{ {
case FIRST: case FIRST:
{ {
item[0].active=true;
if (!smooth) if (!smooth)
{ {
alpha += 0.02f; alpha += 0.02f;
if (alpha >= 1.0f) smooth = true; if (alpha >= 1.0f) smooth = true;
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
} }
if (smooth) alpha -= 0.02f; if (smooth) alpha -= 0.02f;
...@@ -264,16 +260,14 @@ void UpdateGame(void) ...@@ -264,16 +260,14 @@ void UpdateGame(void)
if (!enemy[i].active) enemy[i].active = true; if (!enemy[i].active) enemy[i].active = true;
} }
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = SECOND_WAVE; activeEnemies = SECOND_WAVE;
wave = SECOND; wave = SECOND;
smooth = false; smooth = false;
alpha = 0.0f; alpha = 0.0f;
} }
ItemNumberWave = 2;
} break; } break;
case SECOND: case SECOND:
{ {
if (!smooth) if (!smooth)
...@@ -303,10 +297,6 @@ void UpdateGame(void) ...@@ -303,10 +297,6 @@ void UpdateGame(void)
enemy[i].boss = false; enemy[i].boss = false;
enemy[i].life = 10; enemy[i].life = 10;
} }
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = THIRD_WAVE; activeEnemies = THIRD_WAVE;
wave = THIRD; wave = THIRD;
...@@ -360,16 +350,12 @@ void UpdateGame(void) ...@@ -360,16 +350,12 @@ void UpdateGame(void)
if (!enemy[i].active) enemy[i].active = true; if (!enemy[i].active) enemy[i].active = true;
} }
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = FOURTH_WAVE; activeEnemies = FOURTH_WAVE;
wave = FOURTH; wave = FOURTH;
smooth = false; smooth = false;
alpha = 0.0f; alpha = 0.0f;
} }
ItemNumberWave=3;
} break; } break;
case FOURTH: case FOURTH:
{ {
...@@ -407,11 +393,24 @@ void UpdateGame(void) ...@@ -407,11 +393,24 @@ void UpdateGame(void)
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);
player.life--; player.life--;
}
// Perte du bonus
player.speed.x= 5;
player.speed.y = 5;
for (int i=0; i<NUM_SHOOTS;i++)
{
shoot[i].rec.width = 10;
shoot[i].rec.height = 5;
shoot[i].color = MAROON;
shoot[i].bonus = false;
} }
} }
} }
// Player get item // Player get item
for (int i = 0; i < ItemNumber; i++) for (int i = 0; i < ItemNumber; i++)
{ if (item[i].active)
{ {
if (CheckCollisionRecs(player.rec, item[i].rec)) if (CheckCollisionRecs(player.rec, item[i].rec))
{ {
...@@ -432,14 +431,18 @@ void UpdateGame(void) ...@@ -432,14 +431,18 @@ void UpdateGame(void)
break; break;
case Speed: case Speed:
if (player.speed.x < 10)
{
player.speed.x += 2; player.speed.x += 2;
player.speed.y += 2; player.speed.y += 2;
}
break; break;
case SizeShoot: case SizeShoot:
for (int i; i<NUM_SHOOTS;i++) for (int i=0; i<NUM_SHOOTS;i++)
{ {
shoot[i].bonus = true; shoot[i].bonus = true;
shoot[i].color = YELLOW;
} }
break; break;
default: default:
...@@ -448,6 +451,7 @@ void UpdateGame(void) ...@@ -448,6 +451,7 @@ void UpdateGame(void)
} }
} }
} }
}
// Enemy behaviour // Enemy behaviour
for (int i = 0; i < activeEnemies; i++) for (int i = 0; i < activeEnemies; i++)
...@@ -485,14 +489,13 @@ void UpdateGame(void) ...@@ -485,14 +489,13 @@ void UpdateGame(void)
{ {
if (shoot[i].bonus) if (shoot[i].bonus)
{ {
shoot[i].rec.x = player.rec.x +2; shoot[i].rec.height =10 ;
shoot[i].rec.y = player.rec.y + player.rec.height/4 + 2; shoot[i].rec.width = 20;
shoot[i].active = true; }
}else {
shoot[i].rec.x = player.rec.x; shoot[i].rec.x = player.rec.x;
shoot[i].rec.y = player.rec.y + player.rec.height/4; shoot[i].rec.y = player.rec.y + player.rec.height/4;
shoot[i].active = true; shoot[i].active = true;
}
break; break;
} }
} }
...@@ -529,7 +532,6 @@ void UpdateGame(void) ...@@ -529,7 +532,6 @@ void UpdateGame(void)
score +=100; score +=100;
} }
} }
if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth) if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth)
{ {
shoot[i].active = false; shoot[i].active = false;
...@@ -546,7 +548,6 @@ void UpdateGame(void) ...@@ -546,7 +548,6 @@ void UpdateGame(void)
if (item[i].active) if (item[i].active)
{ {
item[i].rec.x -= item[i].speed.x; item[i].rec.x -= item[i].speed.x;
item[i].effect = GetRandomValue(0,2);
if (item[i].rec.x < 0) if (item[i].rec.x < 0)
{ {
...@@ -599,7 +600,9 @@ void DrawGame(void) ...@@ -599,7 +600,9 @@ void DrawGame(void)
} }
for (int i = 0; i < ItemNumber; i++) for (int i = 0; i < ItemNumber; i++)
{ {
if (item[i].active) DrawRectangleRec(item[i].rec, item[i].color); if (item[i].active) {
DrawRectangleRec(item[i].rec, item[i].color);
}
} }
......
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