Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
Added Weapon Charge Visuals
Browse files Browse the repository at this point in the history
+Added new enum value "CHARGED_LOOP" on enum weapon_status
+Added player ship weapon charged animations
+Added player sprite change when weapon is fully charged, as an animated glow must play over the player's ship.
~Changed SDL_Rect on the player header from a pointer to just a the struct.
  • Loading branch information
ch0m5 committed May 7, 2018
1 parent 2b71481 commit 7d745b2
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 61 deletions.
3 changes: 2 additions & 1 deletion Andro_Dunos/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum weapon_charge_stages // To mark the audio to play when charging the weapon
{
NOT_CHARGING,
CHARGING,
CHARGED
CHARGED,
CHARGED_LOOP
};

// Useful typedefs ---------
Expand Down
124 changes: 95 additions & 29 deletions Andro_Dunos/ModulePlayer1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ ModulePlayer1::ModulePlayer1() // @CarlesHoms @Andres
shipVerticalMovement.PushBack({ 94, 131, shipWidth, shipHeight });
shipVerticalMovement.PushBack({ 94, 153, shipWidth, shipHeight });

shipChargedSuperUp.PushBack({ 257, 66, shipWidth + 5, shipHeight + 6 });
shipChargedSuperUp.PushBack({ 222, 65, shipWidth + 5, shipHeight + 6 });
shipChargedSuperUp.speed = 0.8f;

shipChargedUp.PushBack({ 257, 89, shipWidth + 5, shipHeight + 6 });
shipChargedUp.PushBack({ 222, 88, shipWidth + 5, shipHeight + 6 });
shipChargedUp.speed = 0.8f;

shipCharged.PushBack({ 257, 113, shipWidth + 5, shipHeight + 6 });
shipCharged.PushBack({ 222, 112, shipWidth + 5, shipHeight + 6 });
shipCharged.speed = 0.8f;

shipChargedDown.PushBack({ 257, 138, shipWidth + 5, shipHeight + 6 });
shipChargedDown.PushBack({ 222, 137, shipWidth + 5, shipHeight + 6 });
shipChargedDown.speed = 0.8f;

shipChargedSuperDown.PushBack({ 257, 164, shipWidth + 5, shipHeight + 6 });
shipChargedSuperDown.PushBack({ 222, 163, shipWidth + 5, shipHeight + 6 });
shipChargedSuperDown.speed = 0.8f;

// Booster animations
superUpwardsBooster.PushBack({ 42, 63, propellerWidth, propellerHeight });
superUpwardsBooster.PushBack({ 0, 0, propellerWidth, propellerHeight });
Expand Down Expand Up @@ -254,7 +274,7 @@ update_status ModulePlayer1::Update() // Moves the ship and changes it's printed
{
shipAnimation = &shipVerticalMovement;
propellerAnimation = &idleBooster;
shipRect = &shipAnimation->frames[SHIP_IDLE];
shipRect = shipAnimation->frames[SHIP_IDLE];

// Bliting Text
//App->fonts->BlitText(50, 10, font_score, "we are going to do the best game ric has ever seen dude!!");
Expand Down Expand Up @@ -313,36 +333,71 @@ update_status ModulePlayer1::Update() // Moves the ship and changes it's printed
position.x += speed;
}

// Depending on the vertical counter, we decide the animation

if (movVertical >= maxVertical)
// Depending on the vertical counter and the weapon charge, we decide the animation
if (weaponChargingStage == CHARGED || weaponChargingStage == CHARGED_LOOP)
{
shipRect = &shipAnimation->frames[SHIP_FULL_UP];
propellerAnimation = &superUpwardsBooster;
}
if (movVertical >= maxVertical)
{
shipAnimation = &shipChargedSuperUp;
propellerAnimation = &superUpwardsBooster;
}

else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipRect = &shipAnimation->frames[SHIP_UP];
propellerAnimation = &upwardsBooster;
}
else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipAnimation = &shipChargedUp;
propellerAnimation = &upwardsBooster;
}

else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipRect = &shipAnimation->frames[SHIP_IDLE];
propellerAnimation = &idleBooster;
}
else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipAnimation = &shipCharged;
propellerAnimation = &idleBooster;
}

else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipRect = &shipAnimation->frames[SHIP_DOWN];
propellerAnimation = &downwardsBooster;
else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipAnimation = &shipChargedDown;
propellerAnimation = &downwardsBooster;
}

else if (movVertical <= -maxVertical)
{
shipAnimation = &shipChargedSuperDown;
propellerAnimation = &superDownwardsBooster;
}
}

else if (movVertical <= -maxVertical)
else
{
shipRect = &shipAnimation->frames[SHIP_FULL_DOWN];
propellerAnimation = &superDownwardsBooster;
if (movVertical >= maxVertical)
{
shipRect = shipAnimation->frames[SHIP_FULL_UP];
propellerAnimation = &superUpwardsBooster;
}

else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipRect = shipAnimation->frames[SHIP_UP];
propellerAnimation = &upwardsBooster;
}

else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipRect = shipAnimation->frames[SHIP_IDLE];
propellerAnimation = &idleBooster;
}

else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipRect = shipAnimation->frames[SHIP_DOWN];
propellerAnimation = &downwardsBooster;
}

else if (movVertical <= -maxVertical)
{
shipRect = shipAnimation->frames[SHIP_FULL_DOWN];
propellerAnimation = &superDownwardsBooster;
}
}

// (TEMPORAL) level up and down
Expand Down Expand Up @@ -429,7 +484,6 @@ update_status ModulePlayer1::Update() // Moves the ship and changes it's printed
{
if (bluePower > LEVEL_1)
weaponChargeTimer = SDL_GetTicks();
// weapon charge sound?

blueShotTimer = SDL_GetTicks();

Expand Down Expand Up @@ -887,11 +941,16 @@ update_status ModulePlayer1::Update() // Moves the ship and changes it's printed
Mix_PlayChannel(1, typeCharging, 0);
weaponChargingStage = CHARGING;
}

else if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 2200 && weaponChargingStage == CHARGING)
{
weaponChargingStage = CHARGED;
}

if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 4400 && weaponChargingStage == CHARGING)
else if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 4400 && weaponChargingStage == CHARGED)
{
Mix_PlayChannel(1, typeCharged, -1);
weaponChargingStage = CHARGED;
weaponChargingStage = CHARGED_LOOP;
}
}

Expand Down Expand Up @@ -1008,9 +1067,16 @@ update_status ModulePlayer1::Update() // Moves the ship and changes it's printed
if (destroyed == false)
{
SDL_Rect propellerRect = propellerAnimation->GetCurrentFrame();

App->render->Blit(graphics, position.x - propellerWidth, position.y, &propellerRect, 1.0f, false);
App->render->Blit(graphics, position.x, position.y, shipRect, 1.0f, false);

if (weaponChargingStage == CHARGED || weaponChargingStage == CHARGED_LOOP)
{
shipRect = shipAnimation->GetCurrentFrame();
App->render->Blit(graphics, position.x - 2, position.y - 3, &shipRect, 1.0f, false);
}

else
App->render->Blit(graphics, position.x, position.y, &shipRect, 1.0f, false);
}
}

Expand Down
9 changes: 8 additions & 1 deletion Andro_Dunos/ModulePlayer1.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class ModulePlayer1 : public Module

// Ship and booster animations
Animation shipVerticalMovement;

Animation shipChargedSuperUp;
Animation shipChargedUp;
Animation shipCharged;
Animation shipChargedDown;
Animation shipChargedSuperDown;

Animation superUpwardsBooster;
Animation upwardsBooster;
Animation idleBooster;
Expand All @@ -45,7 +52,7 @@ class ModulePlayer1 : public Module
Animation* crashAnimation = nullptr;

// Player rectangle pointer
SDL_Rect* shipRect;
SDL_Rect shipRect;

// Ship and propeller sizes in pixels
int shipWidth;
Expand Down
124 changes: 95 additions & 29 deletions Andro_Dunos/ModulePlayer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ ModulePlayer2::ModulePlayer2() // @CarlesHoms @Andres
shipVerticalMovement.PushBack({ 154, 131, shipWidth, shipHeight });
shipVerticalMovement.PushBack({ 154, 153, shipWidth, shipHeight });

shipChargedSuperUp.PushBack({ 329, 66, shipWidth + 5, shipHeight + 6 });
shipChargedSuperUp.PushBack({ 294, 65, shipWidth + 5, shipHeight + 6 });
shipChargedSuperUp.speed = 0.8f;

shipChargedUp.PushBack({ 329, 89, shipWidth + 5, shipHeight + 6 });
shipChargedUp.PushBack({ 294, 88, shipWidth + 5, shipHeight + 6 });
shipChargedUp.speed = 0.8f;

shipCharged.PushBack({ 329, 113, shipWidth + 5, shipHeight + 6 });
shipCharged.PushBack({ 294, 112, shipWidth + 5, shipHeight + 6 });
shipCharged.speed = 0.8f;

shipChargedDown.PushBack({ 329, 138, shipWidth + 5, shipHeight + 6 });
shipChargedDown.PushBack({ 294, 137, shipWidth + 5, shipHeight + 6 });
shipChargedDown.speed = 0.8f;

shipChargedSuperDown.PushBack({ 329, 164, shipWidth + 5, shipHeight + 6 });
shipChargedSuperDown.PushBack({ 294, 163, shipWidth + 5, shipHeight + 6 });
shipChargedSuperDown.speed = 0.8f;

// Booster animations
superUpwardsBooster.PushBack({ 42, 63, propellerWidth, propellerHeight });
superUpwardsBooster.PushBack({ 0, 0, propellerWidth, propellerHeight });
Expand Down Expand Up @@ -251,7 +271,7 @@ update_status ModulePlayer2::Update() // Moves the ship and changes it's printed
{
shipAnimation = &shipVerticalMovement;
propellerAnimation = &idleBooster;
shipRect = &shipAnimation->frames[SHIP_IDLE];
shipRect = shipAnimation->frames[SHIP_IDLE];

// Bliting Text
//App->fonts->BlitText(50, 10, font_score, "we are going to do the best game ric has ever seen dude!!");
Expand Down Expand Up @@ -310,36 +330,71 @@ update_status ModulePlayer2::Update() // Moves the ship and changes it's printed
position.x += speed;
}

// Depending on the vertical counter, we decide the animation

if (movVertical >= maxVertical)
// Depending on the vertical counter and the weapon charge, we decide the animation
if (weaponChargingStage == CHARGED || weaponChargingStage == CHARGED_LOOP)
{
shipRect = &shipAnimation->frames[SHIP_FULL_UP];
propellerAnimation = &superUpwardsBooster;
}
if (movVertical >= maxVertical)
{
shipAnimation = &shipChargedSuperUp;
propellerAnimation = &superUpwardsBooster;
}

else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipRect = &shipAnimation->frames[SHIP_UP];
propellerAnimation = &upwardsBooster;
}
else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipAnimation = &shipChargedUp;
propellerAnimation = &upwardsBooster;
}

else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipRect = &shipAnimation->frames[SHIP_IDLE];
propellerAnimation = &idleBooster;
}
else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipAnimation = &shipCharged;
propellerAnimation = &idleBooster;
}

else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipRect = &shipAnimation->frames[SHIP_DOWN];
propellerAnimation = &downwardsBooster;
else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipAnimation = &shipChargedDown;
propellerAnimation = &downwardsBooster;
}

else if (movVertical <= -maxVertical)
{
shipAnimation = &shipChargedSuperDown;
propellerAnimation = &superDownwardsBooster;
}
}

else if (movVertical <= -maxVertical)
else
{
shipRect = &shipAnimation->frames[SHIP_FULL_DOWN];
propellerAnimation = &superDownwardsBooster;
if (movVertical >= maxVertical)
{
shipRect = shipAnimation->frames[SHIP_FULL_UP];
propellerAnimation = &superUpwardsBooster;
}

else if (movVertical > (maxVertical / 2) && movVertical < maxVertical)
{
shipRect = shipAnimation->frames[SHIP_UP];
propellerAnimation = &upwardsBooster;
}

else if (movVertical <= (maxVertical / 2) && movVertical >= -(maxVertical / 2))
{
shipRect = shipAnimation->frames[SHIP_IDLE];
propellerAnimation = &idleBooster;
}

else if (movVertical < -(maxVertical / 2) && movVertical > -maxVertical)
{
shipRect = shipAnimation->frames[SHIP_DOWN];
propellerAnimation = &downwardsBooster;
}

else if (movVertical <= -maxVertical)
{
shipRect = shipAnimation->frames[SHIP_FULL_DOWN];
propellerAnimation = &superDownwardsBooster;
}
}

// (TEMPORAL) level up and down
Expand Down Expand Up @@ -426,7 +481,6 @@ update_status ModulePlayer2::Update() // Moves the ship and changes it's printed
{
if (bluePower > LEVEL_1)
weaponChargeTimer = SDL_GetTicks();
// weapon charge sound?

blueShotTimer = SDL_GetTicks();

Expand Down Expand Up @@ -885,11 +939,16 @@ update_status ModulePlayer2::Update() // Moves the ship and changes it's printed
weaponChargingStage = CHARGING;
}

if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 4400 && weaponChargingStage == CHARGING)
else if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 2200 && weaponChargingStage == CHARGING)
{
Mix_PlayChannel(3, typeCharged, -1);
weaponChargingStage = CHARGED;
}

else if (bluePower > LEVEL_1 && weaponChargeTimer < SDL_GetTicks() - 4400 && weaponChargingStage == CHARGED)
{
Mix_PlayChannel(3, typeCharged, -1);
weaponChargingStage = CHARGED_LOOP;
}
}

// Weapon shot
Expand Down Expand Up @@ -1005,9 +1064,16 @@ update_status ModulePlayer2::Update() // Moves the ship and changes it's printed
if (destroyed == false)
{
SDL_Rect propellerRect = propellerAnimation->GetCurrentFrame();

App->render->Blit(graphics, position.x - propellerWidth, position.y, &propellerRect, 1.0f, false);
App->render->Blit(graphics, position.x, position.y, shipRect, 1.0f, false);

if (weaponChargingStage == CHARGED || weaponChargingStage == CHARGED_LOOP)
{
shipRect = shipAnimation->GetCurrentFrame();
App->render->Blit(graphics, position.x - 2, position.y - 3, &shipRect, 1.0f, false);
}

else
App->render->Blit(graphics, position.x, position.y, &shipRect, 1.0f, false);
}
}

Expand Down
Loading

0 comments on commit 7d745b2

Please sign in to comment.