Skip to content

Commit ddf7e10

Browse files
authored
Merge pull request #122 from casonpollak/ethan
finsihed alt. ending(plan to make exit invisible)
2 parents d19c179 + c99fdf6 commit ddf7e10

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

assets/js/platformer/GameEnv.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export class GameEnv {
5555
* @property {number} timerInterval - Variable to hold the interval reference, used by timer objects
5656
* @property {boolean} keyCollected - Checks whether the key has been collected my Mario or not
5757
* @property {boolean} powerUpCollected - Checks whether the powerup has been collected by the escaper sprite
58-
*/
58+
* @property {boolean} wandColleted - Chekcs whether the wand has been collected by the player
59+
* @property {boolean} spellUsed - Chekcs whether the wand has been used by the player
60+
*/
5961
static userID = "Guest";
6062
static player = null;
6163
static levels = [];
@@ -98,6 +100,9 @@ export class GameEnv {
98100

99101
static trashCount = []
100102

103+
static wandCollected = false;
104+
static spellUsed = false;
105+
101106

102107
// Make the constructor throws an error, or effectively make it a private constructor.
103108
constructor() {

assets/js/platformer/GameSetterQuidditch.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const assets = {
5858
height: 6000, // 204
5959
scaleSize: 10, // 80
6060
speedRatio: 0.7,
61-
opacity: 0,
6261
hitbox: { widthPercentage: 0.4, heightPercentage: -0.2 }
6362
},
6463
},
@@ -129,10 +128,6 @@ const assets = {
129128

130129
};
131130

132-
setTimeout(() => {
133-
alert("Collect wand to progress to next level!");
134-
}, 2000);
135-
136131
// Quidditch Game Level defintion...
137132
const objects = [
138133
// GameObject(s), the order is important to z-index...
@@ -183,7 +178,7 @@ const assets = {
183178
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.375, yPercentage: 0.7 },
184179
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.409, yPercentage: 0.7 },
185180
{ name: 'coin', id: 'coin', class: Coin, data: assets.obstacles.snitch, xPercentage: 0.295, yPercentage: 0.46 },
186-
{ name: 'itemBlock', id: 'JumpPlatform', class: JumpPlatform, data: assets.platforms.itemBlock, xPercentage: 0.5999, yPercentage: 0.6}, //item block is a platform
181+
{ name: 'wand', id: 'JumpPlatform', class: JumpPlatform, data: assets.platforms.itemBlock, xPercentage: 0.5999, yPercentage: 0.6}, //item block is a platform
187182
{ name: 'chocoFrog', id: 'chocoFrog', class: ChocoFrog, data: assets.enemies.chocoFrog, xPercentage: 0.30, yPercentage: 0.45},
188183

189184
{ name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: assets.enemies.magicBeam, xPercentage: 0.623, yPercentage: 0.72 },
@@ -196,9 +191,9 @@ const assets = {
196191
{ name: 'tube', id: 'finishline', class: FinishLine, data: assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.855 },
197192
{ name: 'tubeU', id: 'minifinishline', class: FinishLine, data: assets.obstacles.tubeU, xPercentage: 0.69, yPercentage: 0.9 },
198193
{ name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: assets.transitions.waterEnd },
194+
199195
];
200196

201-
202197

203198
const GameQuidditch = {
204199
tag: 'Quidditch',

assets/js/platformer/PlatformJump.js

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export class JumpPlatform extends GameObject {
3535
this.isVisible = false;
3636
// Update status of key
3737
GameEnv.keyCollected = true
38+
//Update status of the wand
39+
GameEnv.wandCollected = true
3840
// Remove the block from the display
3941
this.canvas.style.display = 'none';
4042
}

assets/js/platformer/PlayerBase.js

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export class PlayerBase extends Character {
127127
} else if (key === 'd') {
128128
this.state.direction = 'right';
129129
}
130+
if (key === 'b' && GameEnv.wandCollected) {
131+
GameEnv.spellUsed = true
132+
}
130133
this.pressedKeys[event.key] = true;
131134
this.updateAnimationState(key);
132135
GameEnv.transitionHide = true;

assets/js/platformer/PlayerQuidditch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class PlayerQuidditch extends PlayerBase {
9292
break;
9393
case "finishline":
9494
// 1. Caught in finishline
95-
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) {
95+
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom && GameEnv.wandCollected && GameEnv.spellUsed) {
9696
// Position player in the center of the finishline
9797
this.x = this.collisionData.newX;
9898
// Using natural gravity wait for player to reach floor

0 commit comments

Comments
 (0)