Commit cd4f5c83 authored by Pierre MARQUE's avatar Pierre MARQUE

Tout fini

parent 2e75d74a
......@@ -90,8 +90,9 @@ Music gamePauseMusic;
const char* explosion = "Musiques/explosion.wav";
const char* alert = "Musiques/Alerte.wav";
const char* bombshellC = "Musiques/Missile-launch-Sound-effect.wav";
const char* bombshellC = "Musiques/Missile.wav";
const char* bulletC = "Musiques/APC.wav";
Wave wave;
Sound soundExplosion;
Sound soundAlert;
Sound soundBombshell ;
......@@ -137,7 +138,10 @@ int main(void)
PlayMusicStream(gamePauseMusic);
UpdateMusicStream(gamePauseMusic);
}
// Update
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
......@@ -233,7 +237,7 @@ void UpdateGame(void)
{
paratrooper[i] = MoveParatrooper(paratrooper[i]);
}
if (IsRectangleOut(paratrooper[i].hitbox))
if (IsRectangleOut(paratrooper[i].hitbox) && paratrooper[i].droped)
{
paratrooper[i] = InitializeParatrooper();
life--;
......@@ -304,12 +308,7 @@ void UpdateGame(void)
{
if (!bombshells[i].ammoShot)
{
bombshells[i].ammoShot = true;
bombshells[i].position.x = antiAircraftCanon.position.x;
bombshells[i].position.y = antiAircraftCanon.position.y;
bombshells[i].speed.x = bombshellSpeed*antiAircraftCanon.cos;
bombshells[i].speed.y = bombshellSpeed*antiAircraftCanon.sin;
PlaySound(soundBombshell);
bombshells[i] = ShootBombshell(bombshells[i]);
break;
}
}
......@@ -321,12 +320,7 @@ void UpdateGame(void)
{
if (!bullet[i].ammoShot)
{
bullet[i].ammoShot = true;
bullet[i].position.x = antiParaCanon.position.x;
bullet[i].position.y = antiParaCanon.position.y;
bullet[i].speed.x = bulletSpeed*antiParaCanon.cos;
bullet[i].speed.y = bulletSpeed*antiParaCanon.sin;
PlaySound(soundBullet);
bullet[i] = ShootBullet(bullet[i]);
break;
}
}
......@@ -399,46 +393,17 @@ void UpdateGame(void)
}
}
//Dropping paratroopers
if (aircraft[i].speed.x>0)
{
if (aircraft[i].hitbox.x > aircraft[i].xFirstToJump)
{
for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++)
{
if ((!paratrooper[j].droped) && (aircraft[i].hitbox.x > aircraft[i].xFirstToJump + 20) && (aircraft[i].numberOfParatroopers > -1))
{
paratrooper[j].droped = true;
paratrooper[j].whichWay = false;
paratrooper[j].hitbox.x = aircraft[i].hitbox.x;
paratrooper[j].hitbox.y = aircraft[i].hitbox.y;
paratrooper[j].xDrop = aircraft[i].hitbox.x;
paratrooper[j].yDrop = aircraft[i].hitbox.y;
aircraft[i].numberOfParatroopers--;
aircraft[i].xFirstToJump = aircraft[i].hitbox.x;
}
}
}
}
else
{
if (aircraft[i].hitbox.x < aircraft[i].xFirstToJump)
{
for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++)
if (GoDropParatrooper(aircraft[i]))
{
for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++)
{
if ((!paratrooper[j].droped) && (fabs(aircraft[i].hitbox.x - aircraft[i].xFirstToJump) > 20) && (aircraft[i].numberOfParatroopers > -1))
{
if ((!paratrooper[j].droped) && (aircraft[i].hitbox.x < aircraft[i].xFirstToJump - 20) && (aircraft[i].numberOfParatroopers > -1))
{
paratrooper[j].droped = true;
paratrooper[j].whichWay = true;
paratrooper[j].xDrop = aircraft[i].hitbox.x;
paratrooper[j].yDrop = aircraft[i].hitbox.y;
paratrooper[j].hitbox.x = aircraft[i].hitbox.x;
paratrooper[j].hitbox.y = aircraft[i].hitbox.y;
aircraft[i].numberOfParatroopers--;
aircraft[i].xFirstToJump = aircraft[i].hitbox.x;
}
paratrooper[j] = DropParatrooperFromAircraft(paratrooper[j],aircraft[i]);
aircraft[i].numberOfParatroopers--;
aircraft[i].xFirstToJump = aircraft[i].hitbox.x;
}
}
}
}
}
}
......@@ -528,7 +493,8 @@ void DrawGame(void)
if (framesCounter % 16 < 8)
{
DrawText("ALERT -- Invaders close to contact --", 0, 500, 20, GREEN);
DrawText(">> <<", paratrooper[i].hitbox.x-12, paratrooper[i].hitbox.y-4, 20, GREEN);
DrawText(">> <<", paratrooper[i].hitbox.x-12, paratrooper[i].hitbox.y-4, 20, GREEN);
PlaySound(soundAlert);
}
}
}
......@@ -566,6 +532,7 @@ void LoadAudio(void)
gameOverMusic = LoadMusicStream(beams);
gamePauseMusic = LoadMusicStream(Dust);
//Sounds
soundExplosion = LoadSound(explosion);
soundBullet = LoadSound(bulletC);
soundBombshell = LoadSound(bombshellC);
......@@ -610,13 +577,13 @@ Aircraft InitializeAircraft(void)
{
aircraft.hitbox.x = -GetRandomValue(0,300);
aircraft.speed.x = 0.5+ 0.5*((float) GetRandomValue(0,1));
aircraft.xFirstToJump = GetRandomValue(100,screenWidth/2);
aircraft.xFirstToJump = GetRandomValue(80,screenWidth/2);
}
else
{
aircraft.speed.x = -(0.5+ 0.5*((float) GetRandomValue(0,1)));
aircraft.hitbox.x = GetRandomValue(screenWidth,screenWidth+300);
aircraft.xFirstToJump = GetRandomValue(screenWidth/2,screenWidth-100);
aircraft.xFirstToJump = GetRandomValue(screenWidth/2,screenWidth-80);
}
aircraft.speed.y = 0;
aircraft.color = GRAY;
......@@ -753,6 +720,19 @@ bool IsCircleOut(Vector2 center, float radius)
return false;
}
bool GoDropParatrooper(Aircraft aircraft)
{
if (aircraft.speed.x>0 && aircraft.hitbox.x > aircraft.xFirstToJump)
{
return true;
}
if (aircraft.speed.x<0 && aircraft.hitbox.x < aircraft.xFirstToJump)
{
return true;
}
return false;
}
Aircraft MoveAircrafts(Aircraft aircraft)
{
aircraft.hitbox.x += aircraft.speed.x;
......@@ -767,6 +747,17 @@ Bullet MoveBullet(Bullet bullet)
return bullet;
}
Bullet ShootBullet(Bullet bullet)
{
bullet.ammoShot = true;
bullet.position.x = antiParaCanon.position.x;
bullet.position.y = antiParaCanon.position.y;
bullet.speed.x = bulletSpeed*antiParaCanon.cos;
bullet.speed.y = bulletSpeed*antiParaCanon.sin;
PlaySound(soundBullet);
return bullet;
}
Bombshell MoveBombshell(Bombshell bombshell)
{
bombshell.position.x += bombshell.speed.x;
......@@ -774,6 +765,35 @@ Bombshell MoveBombshell(Bombshell bombshell)
return bombshell;
}
Bombshell ShootBombshell(Bombshell bombshell)
{
bombshell.ammoShot = true;
bombshell.position.x = antiAircraftCanon.position.x;
bombshell.position.y = antiAircraftCanon.position.y;
bombshell.speed.x = bombshellSpeed*antiAircraftCanon.cos;
bombshell.speed.y = bombshellSpeed*antiAircraftCanon.sin;
PlaySound(soundBombshell);
return bombshell;
}
Paratrooper DropParatrooperFromAircraft(Paratrooper paratrooper, Aircraft aircraft)
{
paratrooper.droped = true;
if (aircraft.speed.x>0)
{
paratrooper.whichWay = false;
}
else
{
paratrooper.whichWay = true;
}
paratrooper.hitbox.x = aircraft.hitbox.x;
paratrooper.hitbox.y = aircraft.hitbox.y;
paratrooper.xDrop = aircraft.hitbox.x;
paratrooper.yDrop = aircraft.hitbox.y;
return paratrooper;
}
Paratrooper MoveParatrooper(Paratrooper paratrooper)
{
paratrooper.hitbox.y += paratrooper.speed.y;
......
No preview for this file type
......@@ -105,8 +105,12 @@ Viewfinder InitializeViewfinder(float decalage);
bool IsRectangleOut(Rectangle rec);
bool IsCircleOut(Vector2 center, float radius);
bool GoDropParatrooper(Aircraft aircraft);
Aircraft MoveAircrafts(Aircraft aircraft);
Bombshell MoveBombshell(Bombshell bombshell);
Bombshell ShootBombshell(Bombshell bombshell);
Bullet MoveBullet(Bullet bullet);
Bullet ShootBullet(Bullet bullet);
Paratrooper DropParatrooperFromAircraft(Paratrooper paratrooper,Aircraft aircraft);
Paratrooper MoveParatrooper(Paratrooper paratrooper);
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