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;
static int activeEnemies = 0;
static int enemiesKill = 0;
static bool smooth = false;
static int ItemNumberWave= 1;
//------------------------------------------------------------------------------------
// Module Functions Declaration (local)
......@@ -222,7 +223,7 @@ void InitGame(void)
item[i].color = GRAY;
break;
}
item[i].active = false;
item[i].active = true;
}
......@@ -241,20 +242,15 @@ void UpdateGame(void)
{
case FIRST:
{
item[0].active=true;
if (!smooth)
{
alpha += 0.02f;
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 (enemiesKill == activeEnemies)
{
enemiesKill = 0;
......@@ -264,16 +260,14 @@ void UpdateGame(void)
if (!enemy[i].active) enemy[i].active = true;
}
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = SECOND_WAVE;
wave = SECOND;
smooth = false;
alpha = 0.0f;
}
ItemNumberWave = 2;
} break;
case SECOND:
{
if (!smooth)
......@@ -284,7 +278,7 @@ void UpdateGame(void)
}
if (smooth) alpha -= 0.02f;
if (enemiesKill == activeEnemies)
{
enemiesKill = 0;
......@@ -303,10 +297,6 @@ void UpdateGame(void)
enemy[i].boss = false;
enemy[i].life = 10;
}
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = THIRD_WAVE;
wave = THIRD;
......@@ -358,18 +348,14 @@ void UpdateGame(void)
for (int i = 0; i < activeEnemies; i++)
{
if (!enemy[i].active) enemy[i].active = true;
}
for (int i = 0; i < ItemNumber; i++)
{
item[i].effect= GetRandomValue(0,2);
}
activeEnemies = FOURTH_WAVE;
wave = FOURTH;
smooth = false;
alpha = 0.0f;
}
ItemNumberWave=3;
} break;
case FOURTH:
{
......@@ -407,44 +393,62 @@ void UpdateGame(void)
enemy[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
enemy[i].rec.y = GetRandomValue(0, screenHeight - enemy[i].rec.height);
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
for (int i = 0; i < ItemNumber; i++)
{
if (CheckCollisionRecs(player.rec, item[i].rec))
{ if (item[i].active)
{
item[i].active = false;
if ( i == ItemNumber -1)
{
item[0].active = true;
}else {
item[i+1].active = true;
}
item[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
item[i].rec.y = GetRandomValue(0, screenHeight - item[i].rec.height);
switch (item[i].effect)
if (CheckCollisionRecs(player.rec, item[i].rec))
{
case Life:
player.life ++;
break;
case Speed:
player.speed.x += 2;
player.speed.y += 2;
break;
case SizeShoot:
for (int i; i<NUM_SHOOTS;i++)
item[i].active = false;
if ( i == ItemNumber -1)
{
shoot[i].bonus = true;
item[0].active = true;
}else {
item[i+1].active = true;
}
item[i].rec.x = GetRandomValue(screenWidth, screenWidth + 1000);
item[i].rec.y = GetRandomValue(0, screenHeight - item[i].rec.height);
switch (item[i].effect)
{
case Life:
player.life ++;
break;
case Speed:
if (player.speed.x < 10)
{
player.speed.x += 2;
player.speed.y += 2;
}
break;
case SizeShoot:
for (int i=0; i<NUM_SHOOTS;i++)
{
shoot[i].bonus = true;
shoot[i].color = YELLOW;
}
break;
default:
break;
}
break;
default:
break;
}
}
}
......@@ -467,7 +471,7 @@ void UpdateGame(void)
}
}
}
// Wall behaviour
if (player.rec.x <= 0) player.rec.x = 0;
if (player.rec.x + player.rec.width >= screenWidth) player.rec.x = screenWidth - player.rec.width;
......@@ -485,14 +489,13 @@ void UpdateGame(void)
{
if (shoot[i].bonus)
{
shoot[i].rec.x = player.rec.x +2;
shoot[i].rec.y = player.rec.y + player.rec.height/4 + 2;
shoot[i].active = true;
}else {
shoot[i].rec.height =10 ;
shoot[i].rec.width = 20;
}
shoot[i].rec.x = player.rec.x;
shoot[i].rec.y = player.rec.y + player.rec.height/4;
shoot[i].active = true;
}
break;
}
}
......@@ -529,7 +532,6 @@ void UpdateGame(void)
score +=100;
}
}
if (shoot[i].rec.x + shoot[i].rec.width >= screenWidth)
{
shoot[i].active = false;
......@@ -546,7 +548,6 @@ void UpdateGame(void)
if (item[i].active)
{
item[i].rec.x -= item[i].speed.x;
item[i].effect = GetRandomValue(0,2);
if (item[i].rec.x < 0)
{
......@@ -599,7 +600,9 @@ void DrawGame(void)
}
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