Skip to content

Commit

Permalink
Merge pull request #119 from casonpollak/VeErA
Browse files Browse the repository at this point in the history
remodel winter level final edits
  • Loading branch information
Parallaxes authored Feb 13, 2025
2 parents ac3a1b0 + 006ab98 commit 7887ac9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 53 deletions.
2 changes: 1 addition & 1 deletion assets/js/platformer/GameControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,4 @@ const GameControl = {
},
};

export default GameControl;
export default GameControl;
29 changes: 23 additions & 6 deletions assets/js/platformer/GameEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ 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
*/
* @property {boolean} wandCollected - Checks whether the wand has been collected by the player
* @property {boolean} spellUsed - Checks whether the wand has been used by the player
*/
static userID = "Guest";
static player = null;
static levels = [];
Expand Down Expand Up @@ -96,12 +97,13 @@ export class GameEnv {

static playerChange = false;

static claimedCoinIds = []
static claimedCoinIds = [];

static trashCount = []
static trashCount = [];

static wandCollected = false;
static spellUsed = false;

static spellUsed = false


// Make the constructor throws an error, or effectively make it a private constructor.
Expand Down Expand Up @@ -264,6 +266,21 @@ export class GameEnv {
break;
}
}

static customTimeout(callback, delay) {
const start = Date.now();

function loop() {
if (Date.now() - start >= delay) {
callback();
} else {
requestAnimationFrame(loop);
}
}

requestAnimationFrame(loop);
}

}

export default GameEnv;
63 changes: 29 additions & 34 deletions assets/js/platformer/GameSetterWinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ const assets = {
sandblock: {src:"/images/platformer/platforms/sandblock.png"},
snowyfloor: { src: "/images/platformer/platforms/grass.png" },
snowywood: { src: "/images/platformer/platforms/snowywood.png" },
boxmiddle: { src: "/images/platformer/platforms/block-left.png"},
boxendleft: {src: "images/platformer/platforms/block-left.png"},
boxendright: {src: "images/platformer/platforms/block-left.png"},
boxback: {src: "images/platformer/platforms/block-left.png"},
boxmiddle_rotated: {src: "images/platformer/platforms/block-left.png"},
boxendleft_rotated: {src: "/images/platformer/platforms/block-left.png"},
boxendright_rotated: {src: "images/platformer/platforms/block-left.png"},
boxmiddle: { src: "/images/platformer/platforms/boxmiddle.png"},
boxendleft: {src: "/images/platformer/platforms/boxendleft.png"},
boxendright: {src: "/images/platformer/platforms/boxendright.png"},
boxback: {src: "/images/platformer/platforms/boxback.png"},
boxmiddle_rotated: {src: "/images/platformer/platforms/boxmiddle_rotated.png"},
boxendleft_rotated: {src: "/images/platformer/platforms/boxendleft_rotated.png"},
boxendright_rotated: {src: "/images/platformer/platforms/boxendright_rotated.png"},
alien: { src: "/images/platformer/platforms/alien.png" },
bricks: { src: "/images/platformer/platforms/brick_wall.png" },
lava: { src: "/images/platformer/platforms/lava.jpg" },
Expand Down Expand Up @@ -459,38 +459,33 @@ const assets = {
{ name: 'winter', id: 'background', class: BackgroundSnow, data: assets.backgrounds.winter },
{ name: 'snowfall', id: 'background', class: BackgroundSnowfall, data: assets.backgrounds.snow },
{ name: 'snowyfloor', id: 'platform', class: Platform, data: assets.platforms.snowyfloor },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.2, yPercentage: 0.82 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.2368, yPercentage: 0.82 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.2736, yPercentage: 0.82 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.3104, yPercentage: 0.82 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.3472, yPercentage: 0.82 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.384, yPercentage: 0.715 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.4208, yPercentage: 0.715 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft_rotated, xPercentage: 0.5090, yPercentage: 0.56 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle_rotated, xPercentage: 0.5090, yPercentage: 0.48 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle_rotated, xPercentage: 0.5090, yPercentage: 0.40 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright_rotated, xPercentage: 0.5090, yPercentage: 0.32 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.655, yPercentage: 0.68 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.62, yPercentage: 0.68 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.72, yPercentage: 0.76 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.69, yPercentage: 0.76 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft_rotated, xPercentage: 0.755, yPercentage: 1 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle_rotated, xPercentage: 0.755, yPercentage: 0.92 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright_rotated, xPercentage: 0.755, yPercentage: 0.84 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright_rotated, xPercentage: 0.625, yPercentage: 0.92 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft_rotated, xPercentage: 0.625, yPercentage: 1 },
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.4, yPercentage: 0.5},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.63, yPercentage: 0.58},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.21, yPercentage: 0.6},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.32, yPercentage: 0.6},
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.25, yPercentage: 0.78 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.2868, yPercentage: 0.78 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.3236, yPercentage: 0.78 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.3604, yPercentage: 0.74 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.3972, yPercentage: 0.7 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.0632, yPercentage: 0.41 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.1, yPercentage: 0.45 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.1368, yPercentage: 0.45 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.1736, yPercentage: 0.48 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.5632, yPercentage: 0.52 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.6, yPercentage: 0.45 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.6368, yPercentage: 0.45 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxmiddle, xPercentage: 0.1368, yPercentage: 0.995 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.755, yPercentage: 0.68 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendleft, xPercentage: 0.72, yPercentage: 0.68 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: assets.platforms.boxendright, xPercentage: 0.789, yPercentage: 0.73 },
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.0632, yPercentage: 0.31},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.36, yPercentage: 0.63},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.565, yPercentage: 0.42},
{ name: 'trash', id: 'trash', class: Trash, data: assets.obstacles.trash, xPercentage: 0.72, yPercentage: 0.58},
{ name: 'owl', id: 'owl', class: Owl, data: assets.enemies.Owl, xPercentage: 0.3, minPosition: 0.05 },
{ name: 'owl', id: 'owl', class: Owl, data: assets.enemies.Owl, xPercentage: 0.8, minPosition: 0.05 },
{ name: 'caveman', id: 'snowman', class: Snowman, data: assets.enemies.Snowman, xPercentage: 0.2, minPosition: 0.1, difficulties: ["normal", "hard", "impossible"] },
{ name: 'caveman', id: 'snowman', class: Snowman, data: assets.enemies.Snowman, xPercentage: 0.35, minPosition: 0.1, difficulties: ["normal", "hard", "impossible"] },
{ name: 'caveman', id: 'snowman', class: Snowman, data: assets.enemies.Snowman, xPercentage: 0.5, minPosition: 0.1, difficulties: ["normal", "hard", "impossible"] },
{ name: 'mario', id: 'player', class: PlayerWinter, data: assets.players.whitemario },
{ name: 'cabin', id: 'finishline', class: FinishLine, data: assets.obstacles.cabin, xPercentage: 0.85, yPercentage: 0.775 },
{ name: 'tubeU', id: 'minifinishline', class: FinishLine, data: assets.obstacles.tubeU, xPercentage: 0.675, yPercentage: 0.8615 },
{ name: 'cabin', id: 'finishline', class: FinishLine, data: assets.obstacles.cabin, xPercentage: 0.85, yPercentage: 0.79 },
{ name: 'quidditchEnd', id: 'background', class: BackgroundTransitions, data: assets.transitions.quidditchEnd },
];

Expand All @@ -500,4 +495,4 @@ const assets = {
objects: objects
};

export default GameSetterWinter;
export default GameSetterWinter;
4 changes: 2 additions & 2 deletions assets/js/platformer/PlatformJump.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class JumpPlatform extends GameObject {

collisionAction() {
// Collision only applies to the item block when Mario collides with it
if (this.collisionData.touchPoints.other.id === "player" && this.name === "itemBlock") {
if (this.collisionData.touchPoints.other.id === "player" && (this.name === "itemBlock" || this.name === "wand")) {
this.handleItemBlockCollision();
}
}
Expand All @@ -40,7 +40,7 @@ export class JumpPlatform extends GameObject {
// Remove the block from the display
this.canvas.style.display = 'none';
}

// Set platform position
size() {
// Formula for Height should be on constant ratio, using a proportion of 832
Expand Down
8 changes: 4 additions & 4 deletions assets/js/platformer/PlayerHills.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ export class PlayerHills extends PlayerBase {
if (this.collisionData.touchPoints.this.right && GameEnv.keyCollected) {
this.state.movement.right = false;
this.state.movement.left = true;
// GameEnv.gameObjects[GameEnv.gameObjects.length - 1].updateImg()
GameEnv.gameObjects[GameEnv.gameObjects.length - 1].updateImg()
// setTimeout(() => {
// this.x = GameEnv.innerWidth + 1;
// }, 1250);
setTimeout(() => {
GameEnv.customTimeout(() => {
GameControl.transitionToLevel(GameEnv.levels[GameEnv.levels.indexOf(GameEnv.currentLevel) + 1]);
}, 1000);
// 3. Collision between player left and finishline
} else if (this.collisionData.touchPoints.this.left && GameEnv.keyCollected) {
this.state.movement.left = false;
this.state.movement.right = true;
// GameEnv.gameObjects[GameEnv.gameObjects.length - 1].updateImg()
GameEnv.gameObjects[GameEnv.gameObjects.length - 1].updateImg()
// setTimeout(() => {
// this.x = GameEnv.innerWidth + 1;
// }, 1250);
setTimeout(() => {
GameEnv.customTimeout(() => {
GameControl.transitionToLevel(GameEnv.levels[GameEnv.levels.indexOf(GameEnv.currentLevel) + 1]);
}, 1000);
}
Expand Down
18 changes: 12 additions & 6 deletions assets/js/platformer/PlayerWinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export class PlayerWinter extends PlayerBase {
this.state.animation = 'idle'
break
}


// Check if the player has collected all the coins
var collectedAllCoins = true;
for (let obj of GameEnv.gameObjects) {
Expand All @@ -117,13 +119,13 @@ export class PlayerWinter extends PlayerBase {
// 1. Caught in finishline
if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) {
// Position player in the center of the finishline
this.x = this.collisionData.newX;
// this.x = this.collisionData.newX;
// Using natural gravity wait for player to reach floor
if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) {
// if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) {
// Force end of level condition
const index = GameEnv.levels.findIndex(level => level.tag === "Skibidi")
GameControl.transitionToLevel(GameEnv.levels[index]);
}
// const index = GameEnv.levels.findIndex(level => level.tag === "Skibidi")
// GameControl.transitionToLevel(GameEnv.levels[index]);
// }
// 2. Collision between player right and finishline
} else if (this.collisionData.touchPoints.this.right) {
this.state.movement.right = false;
Expand All @@ -133,7 +135,11 @@ export class PlayerWinter extends PlayerBase {
this.state.movement.left = false;
this.state.movement.right = true;
}
this.x = GameEnv.innerWidth + 1;
this.canvasHeight = this.canvasHeight * 0.8
this.canvasWidth = this.canvasWidth * 0.8
GameEnv.customTimeout(() => {
this.x = GameEnv.innerWidth + 1; // handles alert to next level
}, 2000);
break;
case "snowman": // Note: Goomba.js and Player.js could be refactored
// 1. Player jumps on goomba, interaction with Goomba.js
Expand Down

0 comments on commit 7887ac9

Please # to comment.