Skip to content

Commit

Permalink
Merge pull request #124 from Parallaxes/bossfight-wip
Browse files Browse the repository at this point in the history
BossFight Hotfix
  • Loading branch information
Parallaxes authored Feb 13, 2025
2 parents 7887ac9 + 365bb73 commit eb730b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions assets/js/platformer/BossFight.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class BossFight extends Character {
isDead: false // New state for checking if Titan is dead
};

this.dead = false;

// Laser-related properties
this.immune = 0;
this.debounce = 0;
Expand All @@ -56,6 +58,8 @@ export class BossFight extends Character {
// Method to handle Titan's death state (makes the Titan disappear)
handleDeath() {
if (this.currentHp <= 0 && !this.state.isDead) {
this.dead = true;
console.log("this.dead set to" + this.dead);
this.state.isDead = true; // Set the Titan as dead
GameEnv.invincible = true; // Make invincible
this.canvas.style.display = "none"; // Hide the Titan's canvas (makes it disappear)
Expand Down
2 changes: 1 addition & 1 deletion assets/js/platformer/GameSetterBossFight.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ const assets = {
{ name: 'shard', id: 'coin', class: Shard, data: assets.obstacles.coin, xPercentage: 0.5, yPercentage: 0.5 },
{ name: 'shard', id: 'coin', class: Shard, data: assets.obstacles.coin, xPercentage: 0.5, yPercentage: 0.5 },
{ name: 'laser', id: 'Laser', class: Laser, data: assets.obstacles.laser, xPercentage: 0.75, yPercentage: 0.5 },
{ name: 'skibidiTitan', id: 'skibidiTitan', class: BossFight, data: assets.enemies.skibidiTitan, xPercentage: 0.35, yPercentage: 0.5, minPosition: 0.5 },
{ name: 'titan', id: 'skibidiTitan', class: BossFight, data: assets.enemies.skibidiTitan, xPercentage: 0.35, yPercentage: 0.5, minPosition: 0.5 },
{ name: 'escaper', id: 'player', class: PlayerBossFight, data: assets.players.escaper },
{ name: 'tolietfinish', id: 'finishline', class: FinishLine, data: assets.obstacles.toiletfinish, xPercentage: 0.85, yPercentage: 0.77 },
{ name: 'complete3', id: 'background', class: BackgroundTransitions, data: assets.backgrounds.complete3 },
Expand Down
6 changes: 5 additions & 1 deletion assets/js/platformer/PlayerBossFight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GameEnv from './GameEnv.js';
import GameControl from './GameControl.js';
import PlayerBaseOneD from './PlayerBaseOneD.js'; ///With this you can change the direction of the sprite sheet with just the sprite rows.
import BossFight from './BossFight.js';

/**
* @class PlayerBossFight class
Expand Down Expand Up @@ -155,7 +156,8 @@ export class PlayerBossFight extends PlayerBaseOneD { /// Using PlayerBaseOneD a
case "finishline":
// 1. Caught in finishline
if (this.collisionData.touchPoints.this.onTopofOther || this.state.isFinishing ) {
if (GameEnv.titan && GameEnv.titan.state.isDead) {
const titan = GameEnv.gameObjects.find(obj => obj.name === 'titan');
if (titan.currentHp <= 0) {
// Position player in the center of the finishline
this.x = this.collisionData.newX;
this.state.movement = { up: false, down: false, left: false, right: false, falling: false};
Expand All @@ -168,6 +170,8 @@ export class PlayerBossFight extends PlayerBaseOneD { /// Using PlayerBaseOneD a
}
} else {
alert("Titan is not dead. You may not proceed");
this.setX(0);
this.state.animation = 'idle';
break;
}

Expand Down

0 comments on commit eb730b4

Please # to comment.