Skip to content

Commit

Permalink
Added cutscene for finall boss
Browse files Browse the repository at this point in the history
  • Loading branch information
mazen366 committed Jul 2, 2023
1 parent ee95f7e commit 8b5213a
Showing 1 changed file with 68 additions and 18 deletions.
86 changes: 68 additions & 18 deletions SP/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Clock timer, timer2, timer4, escTimer, eventTimer, LB_timer;

View view(Vector2f(0, 0), Vector2f(1920, 1080));

bool creditsactive = 1;
bool creditsactive = 1, cutscene, cuton;
const int fadeinT = 2000;
const int fadeoutT = 2000;
const int waitT = 2000;
Expand Down Expand Up @@ -143,6 +143,7 @@ void create(RectangleShape[], int, int, int, int, int);//make ground
void animation(Sprite& s, float maxframe, float x, float y, float delay, int index);
void playerDamageFromEnemy1();
void playerDeathAnimation();
void FBCutScene();
//player
struct Player
{
Expand Down Expand Up @@ -2428,13 +2429,17 @@ struct FINAL_BOSS
boss.damaged(boss);
if (!boss.stopped)
{
cout << "WORKING? " << boss.can_run << '\n';
if (abs(player.upperbodySprite.getPosition().x - boss.sprite.getPosition().x) < 1000)
boss.can_run = 1;
(abs(player.upperbodySprite.getPosition().x - boss.sprite.getPosition().x) < 350&&player.Velocity.x==0) ? boss.can_fight = 1 : boss.can_fight = 0;
if (can_run)
if (boss.can_run)
(boss.can_fight) ? boss.fighting(boss) : boss.running(boss);
else
{
cout << "IDLE\n";
boss.idle(boss);
}
boss.sprite.move(boss.velocity);
}
}
Expand Down Expand Up @@ -3521,21 +3526,30 @@ void cameraView()
leftEnd = 22000;
rightEnd = 22000 + 5120;
//area where no black edges can appear
if (player.upperbodySprite.getPosition().x <= 22000 + 5120 - (1250) && player.upperbodySprite.getPosition().x >= 22000 + (1250))
{
view.setCenter(player.upperbodySprite.getPosition().x, 560); //camera focus on player
}
//area where black edge appear from right
else if (player.upperbodySprite.getPosition().x > 22000 + 5120 - (1250)) //camera stop
if (!cutscene && player.upperbodySprite.getPosition().x > leftEnd + 950)
{
view.setCenter(22000 + 5120 - (1250), 560);
FBCutScene();
cutscene = true;
}
//area where black edge appear from left
else if (player.upperbodySprite.getPosition().x < 22000 + (1250))
else
{
view.setCenter(22000 + (1250), 560); //camera stop
if (player.upperbodySprite.getPosition().x <= 22000 + 5120 - (1250) && player.upperbodySprite.getPosition().x >= 22000 + (1250))
{
view.setCenter(player.upperbodySprite.getPosition().x, 560); //camera focus on player
}
//area where black edge appear from right
else if (player.upperbodySprite.getPosition().x > 22000 + 5120 - (1250)) //camera stop
{
view.setCenter(22000 + 5120 - (1250), 560);
}
//area where black edge appear from left
else if (player.upperbodySprite.getPosition().x < 22000 + (1250))
{
view.setCenter(22000 + (1250), 560); //camera stop
}
}
}

}
void transition()
{
Expand Down Expand Up @@ -3682,11 +3696,14 @@ void plmovement(Sprite& s, float maxframe, float x, float y, float delay, int in
else
{
//functoin -> movement & animation
move_with_animation(s, maxframe, x, y, delay, index);
if (player.gun == PISTOL)
move_with_animation(player.upperbodySprite, maxframe, x, y, delay, index);
else if ((player.gun == RIFLE && rifle.ammo > 0) || player.gun == LISER)
move_with_animation(player.upperbodySprite, 11.9, 528 / 11, 29, delay, 32);
if (!cuton)
{
move_with_animation(s, maxframe, x, y, delay, index);
if (player.gun == PISTOL)
move_with_animation(player.upperbodySprite, maxframe, x, y, delay, index);
else if ((player.gun == RIFLE && rifle.ammo > 0) || player.gun == LISER)
move_with_animation(player.upperbodySprite, 11.9, 528 / 11, 29, delay, 32);
}

}

Expand Down Expand Up @@ -3931,7 +3948,8 @@ void window_draw()
{
window.draw(powerups[i].powerup_sprite);
}
hud.draw(hud);
if(!cuton)
hud.draw(hud);
enemy2->draw(enemy2);
if (boss.live)
window.draw(boss.sprite);
Expand Down Expand Up @@ -4331,6 +4349,38 @@ void texture_setup()//&buffers setup
startvoice.setBuffer(startvoice_B);
startvoice.setVolume(60);
}

void FBCutScene()
{

cuton = true;
Clock t1, t2;
float ctr = 20;
while (t2.getElapsedTime().asSeconds() <= 1)
{
window.clear();

window_draw();
view.setCenter(boss.sprite.getPosition().x, 550);
window.setView(view);


window.display();
}
t1.restart();
while (t1.getElapsedTime().asSeconds() <= 2.5)
{
window.clear();

window_draw();
view.setCenter(boss.sprite.getPosition().x - ctr, 550);
window.setView(view);
window.display();
ctr += 20;
}
cuton = false;

}
void mouse_pos()
{
if (Mouse::isButtonPressed(Mouse::Left))
Expand Down

0 comments on commit 8b5213a

Please sign in to comment.