Commit a0796251 authored by Pierre MARQUE's avatar Pierre MARQUE

Fini mais pas de son

parent 64ca4b53
...@@ -29,13 +29,14 @@ ...@@ -29,13 +29,14 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Some Defines // Some Defines
//--------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
#define NUMBER_MAX_OF_PARATROOPERS 150
#define NUMBER_OF_AIRCRAFTS 10 #define NUMBER_MAX_OF_PARATROOPERS 100
#define NUMBER_MAX_OF_AIRCRAFTS 50
#define NUMBER_OF_BULLETS 25 #define NUMBER_OF_BULLETS 25
#define NUMBER_OF_BOMBSHELLS 25 #define NUMBER_OF_BOMBSHELLS 25
#define TROOPERS_PER_PLANE 5 #define TROOPERS_PER_PLANE 3
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
...@@ -48,12 +49,15 @@ double shoot_rate; ...@@ -48,12 +49,15 @@ double shoot_rate;
static bool gameOver = false; static bool gameOver = false;
static bool pause = false; static bool pause = false;
static int score = 0; int score = 0;
int life = 5;
int NUMBER_OF_AIRCRAFTS =5;
const float bulletSpeed = 10; const float bulletSpeed = 10;
const float bombshellSpeed = 6; const float bombshellSpeed = 6;
float hypothenuse1; float hypothenuse1;
float hypothenuse2; float hypothenuse2;
int framesCounter = 0;
double shoot_rate; double shoot_rate;
double tempsAAC; double tempsAAC;
...@@ -64,12 +68,16 @@ AntiAircraftCanon antiAircraftCanon; ...@@ -64,12 +68,16 @@ AntiAircraftCanon antiAircraftCanon;
Paratrooper paraInitial; Paratrooper paraInitial;
Bombshell bombshellInit; Bombshell bombshellInit;
Bullet bulletInit; Bullet bulletInit;
Viewfinder viewfinder;
int jalon;
Aircraft aircraft[NUMBER_OF_AIRCRAFTS] ; Aircraft aircraft[NUMBER_MAX_OF_AIRCRAFTS] ;
Bullet bullet[NUMBER_OF_BULLETS] ; Bullet bullet[NUMBER_OF_BULLETS] ;
Bombshell bombshells[NUMBER_OF_BOMBSHELLS] ; Bombshell bombshells[NUMBER_OF_BOMBSHELLS] ;
Paratrooper paratrooper[NUMBER_MAX_OF_PARATROOPERS] ; Paratrooper paratrooper[NUMBER_MAX_OF_PARATROOPERS] ;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
...@@ -116,70 +124,80 @@ int main(void) ...@@ -116,70 +124,80 @@ int main(void)
void InitGame(void) void InitGame(void)
{ {
score = 0;
life = 5;
gameOver = false;
pause = false;
jalon = 100;
//Initialize paratroopers //Initialize paratroopers
for (int k=0; k < NUMBER_MAX_OF_PARATROOPERS; k++){ for (int k=0; k < NUMBER_MAX_OF_PARATROOPERS; k++)
paratrooper[k] = InitializeParatrooper(); {
} paratrooper[k] = InitializeParatrooper();
}
//Initialize aircrafts //Initialize aircrafts
for (int i = 0; i < NUMBER_OF_AIRCRAFTS; i++) for (int i = 0; i < NUMBER_MAX_OF_AIRCRAFTS; i++)
{ {
aircraft[i] = InitializeAircraft(); aircraft[i] = InitializeAircraft();
} }
//Initialize bombshells and bullets //Initialize bombshells and bullets
for (int j =0; j< NUMBER_OF_BOMBSHELLS;j++){ for (int j =0; j< NUMBER_OF_BOMBSHELLS;j++)
{
bombshells[j] = InitializeBombshell(); bombshells[j] = InitializeBombshell();
} }
for (int j =0; j< NUMBER_OF_BULLETS; j++){ for (int j =0; j< NUMBER_OF_BULLETS; j++)
{
bullet[j] = InitializeBullet(); bullet[j] = InitializeBullet();
} }
//Initialize canons //Initialize canons
antiParaCanon.sin = 0.; antiParaCanon = InitializeAntiParaCanon();
antiParaCanon.cos = 0.;
antiParaCanon.position.x = screenWidth/4; antiAircraftCanon = InitializeAntiAircraftCanon();
antiParaCanon.position.y = screenHeight;
antiParaCanon.aimingPosition.x = 0.; //Initialize viewfinder
antiParaCanon.aimingPosition.y = 0.; viewfinder = InitializeViewfinder(0.);
antiAircraftCanon.sin = 0.;
antiAircraftCanon.cos = 0.;
antiAircraftCanon.position.x = screenWidth*(0.75);
antiAircraftCanon.position.y = screenHeight;
antiAircraftCanon.aimingPosition.x = 0.;
antiAircraftCanon.aimingPosition.y = 0.;
} }
void UpdateGame(void) void UpdateGame(void)
{ {
if (!gameOver) if (!gameOver)
{ {
if (IsKeyPressed('P')) pause = !pause;
if (!pause) if (!pause)
{ {
//Moves framesCounter++;
if((score > jalon) && (NUMBER_OF_AIRCRAFTS< NUMBER_MAX_OF_AIRCRAFTS)){
NUMBER_OF_AIRCRAFTS+=5;
jalon+=1000;
life +=5 ;
}
//Moves
//Paratroopers //Paratroopers
for(int i = 0; i<NUMBER_MAX_OF_PARATROOPERS; i++ ) for(int i = 0; i<NUMBER_MAX_OF_PARATROOPERS; i++ )
{ {
if(paratrooper[i].droped) if(paratrooper[i].droped)
{ {
paratrooper[i].hitbox.x += paratrooper[i].speed.x; paratrooper[i] = MoveParatrooper(paratrooper[i]);
paratrooper[i].hitbox.y += paratrooper[i].speed.y;
} }
if (IsRectangleOut(paratrooper[i].hitbox)) if (IsRectangleOut(paratrooper[i].hitbox))
{ {
paratrooper[i] = InitializeParatrooper(); paratrooper[i] = InitializeParatrooper();
life--;
gameOver = (life == 0);
} }
} }
//Planes //Planes
for(int j = 0; j<NUMBER_OF_AIRCRAFTS; j++) for(int j = 0; j<NUMBER_OF_AIRCRAFTS; j++)
{ {
aircraft[j].hitbox.x += aircraft[j].speed.x; aircraft[j] = MoveAircrafts(aircraft[j]);
aircraft[j].hitbox.y += aircraft[j].speed.y;
if (IsRectangleOut(aircraft[j].hitbox)) if (IsRectangleOut(aircraft[j].hitbox))
{ {
if (aircraft[j].speed.x>0 && aircraft[j].hitbox.x>screenWidth) if (aircraft[j].speed.x>0 && aircraft[j].hitbox.x>screenWidth)
...@@ -198,8 +216,7 @@ void UpdateGame(void) ...@@ -198,8 +216,7 @@ void UpdateGame(void)
{ {
if (bullet[k].ammoShot) if (bullet[k].ammoShot)
{ {
bullet[k].position.x += bullet[k].speed.x; bullet[k] = MoveBullet(bullet[k]);
bullet[k].position.y += bullet[k].speed.y;
} }
if(IsCircleOut(bullet[k].position,bullet[k].radius)) if(IsCircleOut(bullet[k].position,bullet[k].radius))
{ {
...@@ -212,8 +229,7 @@ void UpdateGame(void) ...@@ -212,8 +229,7 @@ void UpdateGame(void)
{ {
if (bombshells[k].ammoShot) if (bombshells[k].ammoShot)
{ {
bombshells[k].position.x += bombshells[k].speed.x; bombshells[k] = MoveBombshell(bombshells[k]);
bombshells[k].position.y += bombshells[k].speed.y;
} }
if (IsCircleOut(bombshells[k].position,bombshells[k].radius)) if (IsCircleOut(bombshells[k].position,bombshells[k].radius))
{ {
...@@ -235,7 +251,7 @@ void UpdateGame(void) ...@@ -235,7 +251,7 @@ void UpdateGame(void)
//Shooting //Shooting
//anti-aircrafts canon ((double) tempsAAC/CLOCKS_PER_SEC))<(shoot_rate) //anti-aircrafts canon ((double) tempsAAC/CLOCKS_PER_SEC))<(shoot_rate)
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON))
{ {
for (int i = 0; i<NUMBER_OF_BOMBSHELLS; i++) for (int i = 0; i<NUMBER_OF_BOMBSHELLS; i++)
{ {
...@@ -251,7 +267,7 @@ void UpdateGame(void) ...@@ -251,7 +267,7 @@ void UpdateGame(void)
} }
} }
// anti-Paratroopers canon // anti-Paratroopers canon
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON) ) if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) )
{ {
for (int i = 0; i<NUMBER_OF_BULLETS; i++) for (int i = 0; i<NUMBER_OF_BULLETS; i++)
{ {
...@@ -276,13 +292,33 @@ void UpdateGame(void) ...@@ -276,13 +292,33 @@ void UpdateGame(void)
{ {
if(CheckCollisionCircleRec(bullet[j].position, bullet[j].radius, paratrooper[i].hitbox)) if(CheckCollisionCircleRec(bullet[j].position, bullet[j].radius, paratrooper[i].hitbox))
{ {
bullet[j].ammoShot = false; DrawCircleLines(bullet[j].position.x,bullet[j].position.y, bullet[j].radius+20, WHITE);
DrawCircleLines(bullet[j].position.x+4,bullet[j].position.y, 10, YELLOW);
DrawCircleLines(bullet[j].position.x+8,bullet[j].position.y, 5, RED);
paratrooper[i].life--; paratrooper[i].life--;
Vector2 v = bullet[j].position;
bullet[j].ammoShot = false;
//Kill paras //Kill paras
if(paratrooper[i].life == 0) if(paratrooper[i].life == 0)
{ {
paratrooper[i] = InitializeParatrooper(); paratrooper[i] = InitializeParatrooper();
} }
//explosive ammo
for (int s = 0; s<NUMBER_MAX_OF_PARATROOPERS; s++)
{
if(paratrooper[s].droped)
{
if(CheckCollisionCircleRec(v, bullet[j].radius+20, paratrooper[s].hitbox))
{
paratrooper[s].life--;
//Kill paras
if(paratrooper[s].life == 0)
{
paratrooper[s] = InitializeParatrooper();
}
}
}
}
} }
} }
} }
...@@ -297,9 +333,17 @@ void UpdateGame(void) ...@@ -297,9 +333,17 @@ void UpdateGame(void)
if(CheckCollisionCircleRec(bombshells[j].position, bombshells[j].radius, aircraft[i].hitbox)) if(CheckCollisionCircleRec(bombshells[j].position, bombshells[j].radius, aircraft[i].hitbox))
{ {
bombshells[j].ammoShot = false; bombshells[j].ammoShot = false;
DrawCircle(bombshells[j].position.x,bombshells[j].position.y, 15, RED);
DrawCircle(bombshells[j].position.x+4,bombshells[j].position.y, 10, YELLOW);
aircraft[i].life = aircraft[i].life - 1; aircraft[i].life = aircraft[i].life - 1;
//Kill aircrafts //Kill aircrafts
if(aircraft[i].life == 0){ if(aircraft[i].life == 0)
{
score+=50;
DrawCircle(aircraft[i].hitbox.x,aircraft[i].hitbox.y, 15, WHITE);
DrawCircle(aircraft[i].hitbox.x+4,aircraft[i].hitbox.y, 10, YELLOW);
DrawCircle(aircraft[i].hitbox.x+8,aircraft[i].hitbox.y, 5, RED);
aircraft[i] = InitializeAircraft(); aircraft[i] = InitializeAircraft();
} }
} }
...@@ -311,11 +355,14 @@ void UpdateGame(void) ...@@ -311,11 +355,14 @@ void UpdateGame(void)
{ {
for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++) for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++)
{ {
if ((!paratrooper[j].droped) && (aircraft[i].hitbox.x > aircraft[i].xFirstToJump + 50) && (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].droped = true;
paratrooper[j].whichWay = false;
paratrooper[j].hitbox.x = aircraft[i].hitbox.x; paratrooper[j].hitbox.x = aircraft[i].hitbox.x;
paratrooper[j].hitbox.y = aircraft[i].hitbox.y; 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].numberOfParatroopers--;
aircraft[i].xFirstToJump = aircraft[i].hitbox.x; aircraft[i].xFirstToJump = aircraft[i].hitbox.x;
...@@ -329,9 +376,12 @@ void UpdateGame(void) ...@@ -329,9 +376,12 @@ void UpdateGame(void)
{ {
for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++) for(int j = 0; j<NUMBER_MAX_OF_PARATROOPERS; j++)
{ {
if ((!paratrooper[j].droped) && (aircraft[i].hitbox.x < aircraft[i].xFirstToJump - 50) && (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].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.x = aircraft[i].hitbox.x;
paratrooper[j].hitbox.y = aircraft[i].hitbox.y; paratrooper[j].hitbox.y = aircraft[i].hitbox.y;
aircraft[i].numberOfParatroopers--; aircraft[i].numberOfParatroopers--;
...@@ -340,9 +390,16 @@ void UpdateGame(void) ...@@ -340,9 +390,16 @@ void UpdateGame(void)
} }
} }
} }
} }
} }
}
}
else
{
if (IsKeyPressed(KEY_ENTER))
{
InitGame();
gameOver = false;
} }
} }
} }
...@@ -351,7 +408,7 @@ void DrawGame(void) ...@@ -351,7 +408,7 @@ void DrawGame(void)
{ {
BeginDrawing(); BeginDrawing();
ClearBackground(SKYBLUE); ClearBackground(BLACK);
if (!gameOver) if (!gameOver)
{ {
...@@ -359,6 +416,7 @@ void DrawGame(void) ...@@ -359,6 +416,7 @@ void DrawGame(void)
for (int i = 0; i<NUMBER_OF_AIRCRAFTS; i++) for (int i = 0; i<NUMBER_OF_AIRCRAFTS; i++)
{ {
DrawRectangleRec(aircraft[i].hitbox, aircraft[i].color); DrawRectangleRec(aircraft[i].hitbox, aircraft[i].color);
} }
//Draw paratroopers //Draw paratroopers
for (int i = 0; i<NUMBER_MAX_OF_PARATROOPERS; i++) for (int i = 0; i<NUMBER_MAX_OF_PARATROOPERS; i++)
...@@ -366,7 +424,12 @@ void DrawGame(void) ...@@ -366,7 +424,12 @@ void DrawGame(void)
if (paratrooper[i].droped) if (paratrooper[i].droped)
{ {
DrawRectangleRec(paratrooper[i].hitbox, paratrooper[i].color); DrawRectangleRec(paratrooper[i].hitbox, paratrooper[i].color);
if (framesCounter % 32 < 16)
{
DrawRectangleRec(paratrooper[i].hitbox, ORANGE);;
}
} }
//Draw drag
} }
//Draw bullets //Draw bullets
for (int i = 0; i<NUMBER_OF_BULLETS; i++) for (int i = 0; i<NUMBER_OF_BULLETS; i++)
...@@ -374,6 +437,7 @@ void DrawGame(void) ...@@ -374,6 +437,7 @@ void DrawGame(void)
if (bullet[i].ammoShot) if (bullet[i].ammoShot)
{ {
DrawCircleV(bullet[i].position, bullet[i].radius, bullet[i].color); DrawCircleV(bullet[i].position, bullet[i].radius, bullet[i].color);
} }
} }
//Draw bombshells //Draw bombshells
...@@ -381,13 +445,61 @@ void DrawGame(void) ...@@ -381,13 +445,61 @@ void DrawGame(void)
{ {
if (bombshells[i].ammoShot) if (bombshells[i].ammoShot)
{ {
DrawCircleV(bombshells[i].position, bombshells[i].radius,bombshells[i].color); DrawCircleV(bombshells[i].position, bombshells[i].radius-10,bombshells[i].color);
if (framesCounter % 32 < 16)
{
DrawText( "< >", bombshells[i].position.x -4 ,bombshells[i].position.y -2, 15, GREEN);
}
}
}
if (pause){ DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GREEN);}
}
else
{
DrawText("Press ENTER to play again", 450, 250, 20, GREEN);
}
//ATH
//Beware of paras
for (int i = 0; i<NUMBER_MAX_OF_PARATROOPERS; i++)
{
if (paratrooper[i].droped)
{
if (paratrooper[i].hitbox.y>350)
{
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);
}
} }
} }
//Draw viewfinder
DrawCircleV(GetMousePosition(),5, RED);
} }
//Draw viewfinder
if((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) || (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)))
{
viewfinder = InitializeViewfinder(10);
}
else
{
viewfinder = InitializeViewfinder(15);
}
DrawRectangleRec(viewfinder.up,viewfinder.color);
DrawRectangleRec(viewfinder.down,viewfinder.color);
DrawRectangleRec(viewfinder.right,viewfinder.color);
DrawRectangleRec(viewfinder.left,viewfinder.color);
//Score
DrawText("\\>>>|", 500, 500, 20, GREEN);
DrawText(TextFormat("%04i",score), 550, 500, 20, GREEN);
DrawText("|<<</", 600, 500, 20, GREEN);
DrawText(TextFormat("LIVES = %04i",life), 510, 520, 20, GREEN);
EndDrawing(); EndDrawing();
} }
...@@ -399,7 +511,7 @@ void DrawGame(void) ...@@ -399,7 +511,7 @@ void DrawGame(void)
Aircraft InitializeAircraft(void) Aircraft InitializeAircraft(void)
{ {
Aircraft aircraft; Aircraft aircraft;
aircraft.life = 2; aircraft.life = 1;
aircraft.hitbox.width = GetRandomValue(30,50); aircraft.hitbox.width = GetRandomValue(30,50);
aircraft.hitbox.height = 5; aircraft.hitbox.height = 5;
aircraft.numberOfParatroopers = GetRandomValue(0,TROOPERS_PER_PLANE); aircraft.numberOfParatroopers = GetRandomValue(0,TROOPERS_PER_PLANE);
...@@ -412,27 +524,52 @@ Aircraft InitializeAircraft(void) ...@@ -412,27 +524,52 @@ Aircraft InitializeAircraft(void)
aircraft.hitbox.width = 50; aircraft.hitbox.width = 50;
} }
aircraft.hitbox.y = GetRandomValue(0 + aircraft.hitbox.height, screenHeight/2); aircraft.hitbox.y = GetRandomValue(0 + aircraft.hitbox.height, screenHeight/2);
aircraft.height = aircraft.hitbox.y;
if (GetRandomValue(0,1)==0) if (GetRandomValue(0,1)==0)
{ {
aircraft.hitbox.x = -GetRandomValue(0,300); aircraft.hitbox.x = -GetRandomValue(0,300);
aircraft.speed.x = 0.5+ 0.5*((float) GetRandomValue(0,1)); aircraft.speed.x = 0.5+ 0.5*((float) GetRandomValue(0,1));
aircraft.xFirstToJump = GetRandomValue(10,screenWidth/2); aircraft.xFirstToJump = GetRandomValue(100,screenWidth/2);
} }
else else
{ {
aircraft.speed.x = -(0.5+ 0.5*((float) GetRandomValue(0,1))); aircraft.speed.x = -(0.5+ 0.5*((float) GetRandomValue(0,1)));
aircraft.hitbox.x = GetRandomValue(screenWidth,screenWidth+300); aircraft.hitbox.x = GetRandomValue(screenWidth,screenWidth+300);
aircraft.xFirstToJump = GetRandomValue(screenWidth/2,screenWidth-10); aircraft.xFirstToJump = GetRandomValue(screenWidth/2,screenWidth-100);
} }
aircraft.speed.y = 0; aircraft.speed.y = 0;
aircraft.color = GRAY; aircraft.color = GRAY;
return aircraft; return aircraft;
} }
AntiAircraftCanon InitializeAntiAircraftCanon(void)
{
AntiAircraftCanon antiAircraftCanon;
antiAircraftCanon.sin = 0.;
antiAircraftCanon.cos = 0.;
antiAircraftCanon.position.x = screenWidth*(0.75);
antiAircraftCanon.position.y = screenHeight;
antiAircraftCanon.aimingPosition.x = 0.;
antiAircraftCanon.aimingPosition.y = 0.;
return antiAircraftCanon;
}
AntiParaCanon InitializeAntiParaCanon(void)
{
AntiParaCanon antiParaCanon;
antiParaCanon.sin = 0.;
antiParaCanon.cos = 0.;
antiParaCanon.position.x = screenWidth/4;
antiParaCanon.position.y = screenHeight;
antiParaCanon.aimingPosition.x = 0.;
antiParaCanon.aimingPosition.y = 0.;
return antiParaCanon;
}
Bombshell InitializeBombshell(void) Bombshell InitializeBombshell(void)
{ {
Bombshell bombshellInit; Bombshell bombshellInit;
bombshellInit.radius = 7; bombshellInit.radius = 15;
bombshellInit.sin = 0; bombshellInit.sin = 0;
bombshellInit.cos = 0; bombshellInit.cos = 0;
bombshellInit.ammoShot = false; bombshellInit.ammoShot = false;
...@@ -440,8 +577,8 @@ Bombshell InitializeBombshell(void) ...@@ -440,8 +577,8 @@ Bombshell InitializeBombshell(void)
bombshellInit.position.y = 0; bombshellInit.position.y = 0;
bombshellInit.speed.x = 0; bombshellInit.speed.x = 0;
bombshellInit.speed.y = 0; bombshellInit.speed.y = 0;
bombshellInit.color = RED; bombshellInit.color = DARKPURPLE;
return bombshellInit; return bombshellInit;
} }
Bullet InitializeBullet(void) Bullet InitializeBullet(void)
...@@ -462,16 +599,52 @@ Bullet InitializeBullet(void) ...@@ -462,16 +599,52 @@ Bullet InitializeBullet(void)
Paratrooper InitializeParatrooper(void) Paratrooper InitializeParatrooper(void)
{ {
Paratrooper paraInitial; Paratrooper paraInitial;
paraInitial.speed.y = 0.7; paraInitial.hitbox.x = 0;
paraInitial.hitbox.y = 0;
paraInitial.xDrop = 0.;
paraInitial.yDrop = 0.;
paraInitial.speed.y = 0.3;
paraInitial.speed.x = 0; paraInitial.speed.x = 0;
paraInitial.color = RED; paraInitial.color = RED;
paraInitial.life = 2; paraInitial.life = 1;
paraInitial.hitbox.width = 10; paraInitial.hitbox.width = 10;
paraInitial.hitbox.height = 10; paraInitial.hitbox.height = 10;
paraInitial.droped = false; paraInitial.droped = false;
paraInitial.whichWay = true;
return paraInitial; return paraInitial;
} }
Viewfinder InitializeViewfinder(float decalage)
{
Viewfinder v;
v.color = GREEN;
float d1 = 13;
float d2 = 2;
v.center = GetMousePosition();
v.up.width = d2;
v.up.height = d1;
v.up.y = v.center.y + decalage - d1/2 ;
v.up.x = v.center.x -d2/2 ;
v.down.width = d2;
v.down.height = d1;
v.down.y = v.center.y - decalage - d1/2;
v.down.x = v.center.x - d2/2;
v.right.width = d1;
v.right.height =d2;
v.right.x = v.center.x + decalage -d1/2;
v.right.y = v.center.y - d2/2;
v.left.width = d1;
v.left.height = d2;
v.left.x = v.center.x - decalage - d1/2;
v.left.y = v.center.y - d2/2;
return v;
}
//Game Functions------------------------------------------------------------------------- //Game Functions-------------------------------------------------------------------------
bool IsRectangleOut(Rectangle rec) bool IsRectangleOut(Rectangle rec)
{ {
...@@ -498,3 +671,39 @@ bool IsCircleOut(Vector2 center, float radius) ...@@ -498,3 +671,39 @@ bool IsCircleOut(Vector2 center, float radius)
} }
return false; return false;
} }
Aircraft MoveAircrafts(Aircraft aircraft)
{
aircraft.hitbox.x += aircraft.speed.x;
aircraft.hitbox.y = aircraft.height + 10*cos(0.01*aircraft.hitbox.x);
return aircraft;
}
Bullet MoveBullet(Bullet bullet)
{
bullet.position.x += bullet.speed.x;
bullet.position.y += bullet.speed.y;
return bullet;
}
Bombshell MoveBombshell(Bombshell bombshell)
{
bombshell.position.x += bombshell.speed.x;
bombshell.position.y += bombshell.speed.y;
return bombshell;
}
Paratrooper MoveParatrooper(Paratrooper paratrooper)
{
paratrooper.hitbox.y += paratrooper.speed.y;
if(paratrooper.whichWay)
{
paratrooper.hitbox.x = 100*(1-exp(-(paratrooper.hitbox.y-paratrooper.yDrop)/5)) + paratrooper.xDrop;
}
else
{
paratrooper.hitbox.x = -100*(1-exp(-(paratrooper.hitbox.y-paratrooper.yDrop)/5)) + paratrooper.xDrop;
}
return paratrooper;
}
No preview for this file type
...@@ -6,15 +6,20 @@ ...@@ -6,15 +6,20 @@
typedef struct Paratrooper typedef struct Paratrooper
{ {
int life; int life;
float xDrop;
float yDrop;
bool droped; bool droped;
bool whichWay;
Rectangle hitbox; Rectangle hitbox;
Vector2 speed; Vector2 speed;
Color color; // yellow or red Color color; // yellow or red
Rectangle drag[10];
}Paratrooper; }Paratrooper;
typedef struct Aircraft typedef struct Aircraft
{ {
int life; int life;
float height;
float xFirstToJump; float xFirstToJump;
int numberOfParatroopers; int numberOfParatroopers;
Rectangle hitbox; Rectangle hitbox;
...@@ -61,12 +66,24 @@ typedef struct AntiParaCanon ...@@ -61,12 +66,24 @@ typedef struct AntiParaCanon
Vector2 aimingPosition; Vector2 aimingPosition;
}AntiParaCanon; }AntiParaCanon;
typedef struct Viewfinder
{
Rectangle up;
Rectangle down;
Rectangle left;
Rectangle right;
float radius;
Vector2 center;
Color color;
}Viewfinder;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static void InitGame(void); // Initialize game static void InitGame(void); // Initialize game
static void UpdateGame(); // Update game (one frame) static void UpdateGame(void); // Update game (one frame)
static void DrawGame(void); // Draw game (one frame) static void DrawGame(void); // Draw game (one frame)
static void UnloadGame(void); // Unload game static void UnloadGame(void); // Unload game
...@@ -76,11 +93,19 @@ static void UnloadGame(void); // Unload game ...@@ -76,11 +93,19 @@ static void UnloadGame(void); // Unload game
//Initialization functions------------------------------------------------------------ //Initialization functions------------------------------------------------------------
Aircraft InitializeAircraft(void); Aircraft InitializeAircraft(void);
AntiAircraftCanon InitializeAntiAircraftCanon(void);
AntiParaCanon InitializeAntiParaCanon(void);
Bombshell InitializeBombshell(void); Bombshell InitializeBombshell(void);
Bullet InitializeBullet(void); Bullet InitializeBullet(void);
Paratrooper InitializeParatrooper(void); Paratrooper InitializeParatrooper(void);
Viewfinder InitializeViewfinder(float decalage);
//Game functions---------------------------------------------------------------------- //Game functions----------------------------------------------------------------------
bool IsRectangleOut(Rectangle rec); bool IsRectangleOut(Rectangle rec);
bool IsCircleOut(Vector2 center, float radius); bool IsCircleOut(Vector2 center, float radius);
Aircraft MoveAircrafts(Aircraft aircraft);
Bombshell MoveBombshell(Bombshell bombshell);
Bullet MoveBullet(Bullet bullet);
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