Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

finsihed alt. ending(plan to make exit invisible) #122

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion assets/js/platformer/GameEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export class GameEnv {
* @property {number} timerInterval - Variable to hold the interval reference, used by timer objects
* @property {boolean} keyCollected - Checks whether the key has been collected my Mario or not
* @property {boolean} powerUpCollected - Checks whether the powerup has been collected by the escaper sprite
*/
* @property {boolean} wandColleted - Chekcs whether the wand has been collected by the player
* @property {boolean} spellUsed - Chekcs whether the wand has been used by the player
*/
static userID = "Guest";
static player = null;
static levels = [];
Expand Down Expand Up @@ -98,6 +100,9 @@ export class GameEnv {

static trashCount = []

static wandCollected = false;
static spellUsed = false;


// Make the constructor throws an error, or effectively make it a private constructor.
constructor() {
Expand Down
9 changes: 2 additions & 7 deletions assets/js/platformer/GameSetterQuidditch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const assets = {
height: 6000, // 204
scaleSize: 10, // 80
speedRatio: 0.7,
opacity: 0,
hitbox: { widthPercentage: 0.4, heightPercentage: -0.2 }
},
},
Expand Down Expand Up @@ -129,10 +128,6 @@ const assets = {

};

setTimeout(() => {
alert("Collect wand to progress to next level!");
}, 2000);

// Quidditch Game Level defintion...
const objects = [
// GameObject(s), the order is important to z-index...
Expand Down Expand Up @@ -183,7 +178,7 @@ const assets = {
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.375, yPercentage: 0.7 },
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.409, yPercentage: 0.7 },
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.295, yPercentage: 0.46 },
{ name: 'itemBlock', id: 'JumpPlatform', class: JumpPlatform, data: assets.platforms.itemBlock, xPercentage: 0.5999, yPercentage: 0.6}, //item block is a platform
{ name: 'wand', id: 'JumpPlatform', class: JumpPlatform, data: assets.platforms.itemBlock, xPercentage: 0.5999, yPercentage: 0.6}, //item block is a platform
{ name: 'chocoFrog', id: 'chocoFrog', class: ChocoFrog, data: assets.enemies.chocoFrog, xPercentage: 0.30, yPercentage: 0.45},

{ name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: assets.enemies.magicBeam, xPercentage: 0.623, yPercentage: 0.72 },
Expand All @@ -196,9 +191,9 @@ const assets = {
{ name: 'tube', id: 'finishline', class: FinishLine, data: assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.855 },
{ name: 'tubeU', id: 'minifinishline', class: FinishLine, data: assets.obstacles.tubeU, xPercentage: 0.69, yPercentage: 0.9 },
{ name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: assets.transitions.waterEnd },

];



const GameQuidditch = {
tag: 'Quidditch',
Expand Down
2 changes: 2 additions & 0 deletions assets/js/platformer/PlatformJump.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class JumpPlatform extends GameObject {
this.isVisible = false;
// Update status of key
GameEnv.keyCollected = true
//Update status of the wand
GameEnv.wandCollected = true
// Remove the block from the display
this.canvas.style.display = 'none';
}
Expand Down
3 changes: 3 additions & 0 deletions assets/js/platformer/PlayerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export class PlayerBase extends Character {
} else if (key === 'd') {
this.state.direction = 'right';
}
if (key === 'b' && GameEnv.wandCollected) {
GameEnv.spellUsed = true
}
this.pressedKeys[event.key] = true;
this.updateAnimationState(key);
GameEnv.transitionHide = true;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/platformer/PlayerQuidditch.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class PlayerQuidditch extends PlayerBase {
break;
case "finishline":
// 1. Caught in finishline
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) {
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom && GameEnv.wandCollected && GameEnv.spellUsed) {
// Position player in the center of the finishline
this.x = this.collisionData.newX;
// Using natural gravity wait for player to reach floor
Expand Down