From cb393c6ff39b1c345c32fd567c8ea17b1b8c0fc6 Mon Sep 17 00:00:00 2001 From: areebaahmed Date: Fri, 17 May 2024 14:12:16 -0700 Subject: [PATCH 01/13] Chocolate Frog --- assets/js/platformer3x/ChocoFrog.js | 113 ++++++++++++++++++ assets/js/platformer3x/GameEnv.js | 2 + assets/js/platformer3x/GameSetup.js | 18 ++- assets/js/platformer3x/SpawnPlatform.js | 2 +- images/platformer/platforms/Chocolatefrog.jpg | Bin 0 -> 8474 bytes 5 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 assets/js/platformer3x/ChocoFrog.js create mode 100644 images/platformer/platforms/Chocolatefrog.jpg diff --git a/assets/js/platformer3x/ChocoFrog.js b/assets/js/platformer3x/ChocoFrog.js new file mode 100644 index 00000000..699dbfdb --- /dev/null +++ b/assets/js/platformer3x/ChocoFrog.js @@ -0,0 +1,113 @@ +import Character from './Character.js'; +import GameEnv from './GameEnv.js'; +import GameControl from './GameControl.js'; + +export class ChocoFrog extends Character { + // constructors sets up Character object + constructor(canvas, image, data, xPercentage, yPercentage, name, minPosition){ + super(canvas, image, data); + + //Unused but must be Defined + this.name = name; + this.y = yPercentage; + + //Initial Position + this.x = xPercentage * GameEnv.innerWidth; + + + this.minPosition = minPosition * GameEnv.innerWidth; + this.maxPosition = this.x + xPercentage * GameEnv.innerWidth; + + this.immune = 0; + } + + update() { + super.update(); + + // Check for boundaries + if (this.x <= this.minPosition || (this.x + this.canvasWidth >= this.maxPosition)) { + this.speed = -this.speed; + }; + + // Random Event 2 + if (GameControl.randomEventId === 2 && GameControl.randomEventState === 1) { + this.speed = 0; + if (this.name === "goombaSpecial") { + GameControl.endRandomEvent(); + }; + }; + + + + if (GameControl.randomEventId === 3 && GameControl.randomEventState === 1) { + this.destroy(); + GameControl.endRandomEvent(); + }; + + + // Chance for Mushroom to turn Gold + if (["normal", "hard"].includes(GameEnv.difficulty)) { + if (Math.random() < 0.00001) { + this.canvas.style.filter = 'brightness(1000%)'; + this.immune = 1; + } + } + + // Immunize & Texture It + if (GameEnv.difficulty === "hard") { + this.canvas.style.filter = "invert(100%)"; + this.canvas.style.scale = 1.25; + this.immune = 1; + } else if (GameEnv.difficulty === "impossible") { + this.canvas.style.filter = 'brightness(1000%)'; + this.immune = 1; + } + + // Remove the line that updates the x position based on speed + // this.x -= this.speed; + + this.playerBottomCollision = false; + } + + + // Player action on collisions + collisionAction() { + if (this.collisionData.touchPoints.other.id === "tube") { + if (this.collisionData.touchPoints.other.left || this.collisionData.touchPoints.other.right) { + this.speed = -this.speed; + } + } + + if (this.collisionData.touchPoints.other.id === "player") { + // Collision: Top of Goomba with Bottom of Player + //console.log(this.collisionData.touchPoints.other.bottom + 'bottom') + //console.log(this.collisionData.touchPoints.other.top + "top") + //console.log(this.collisionData.touchPoints.other.right + "right") + //console.log(this.collisionData.touchPoints.other.left + "left") + if (this.collisionData.touchPoints.other.bottom && this.immune == 0) { + GameEnv.invincible = true; + GameEnv.goombaBounce1 = true; + this.canvas.style.transition = "transform 1.5s, opacity 1s"; + this.canvas.style.transition = "transform 2s, opacity 1s"; + this.canvas.style.transformOrigin = "bottom"; + this.canvas.style.transform = "scaleY(0)"; + this.speed = 0; + GameEnv.playSound("Mushroom"); + + setTimeout((function() { + GameEnv.invincible = false; + this.destroy(); + GameEnv.destroyedChocoFrog = true; + }).bind(this), 1500); + } + + } + if (this.collisionData.touchPoints.other.id === "jumpPlatform") { + if (this.collisionData.touchPoints.other.left || this.collisionData.touchPoints.other.right) { + this.speed = -this.speed; + } + } + } +} + +export default ChocoFrog; \ No newline at end of file diff --git a/assets/js/platformer3x/GameEnv.js b/assets/js/platformer3x/GameEnv.js index d952c214..5895b327 100644 --- a/assets/js/platformer3x/GameEnv.js +++ b/assets/js/platformer3x/GameEnv.js @@ -42,6 +42,7 @@ export class GameEnv { * @property {number} gravity - localstorage key, used by platformer objects * @property {boolean} destroyedMushroom - to see when mushroom is destroyed * @property {boolean} destroyedMagicBeam - to see when magic beam is destroyed + * @property {boolean} destroyedChocoFrog - to see when chocofrog is destroyed * @property {boolean} playMessage * @property {Object} difficulty - localstorage key, used by GameControl * @property {number} innerWidth - used by platformer objects @@ -65,6 +66,7 @@ export class GameEnv { static gravity = 3; static destroyedMushroom = false; static destroyedMagicBeam = false; + static destroyedChocoFrog = false; static playMessage = false; static difficulty = "normal"; static innerWidth; diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 97d948fe..aec75c49 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -28,7 +28,8 @@ import BlockPlatform from './BlockPlatform.js'; import SpawnPlatform from './SpawnPlatform.js'; import MovingPlatform from './MovingPlatform.js' import Mushroom from './Mushroom.js'; -import MagicBeam from './MagicBeam.js' +import MagicBeam from './MagicBeam.js'; +import ChocoFrog from './ChocoFrog.js'; import Coin from './Coin.js'; import Snowflake from './Snowflake.js'; import GameControl from './GameControl.js'; @@ -504,6 +505,12 @@ const GameSetup = { height: 400, hitbox: { widthPercentage: 0.5, heightPercentage: 0.5 } }, + chocoFrog: { + src: "/images/platformer/platforms/Chocolatefrog.jpg", + width: 200, + height: 200, + hitbox: { widthPercentage: 0.0, heightPercentage: 0.0 } + }, alien: { src: "/images/platformer/sprites/alien.png", width: 444, @@ -878,9 +885,9 @@ const GameSetup = { { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.30, yPercentage: 0.33 }, { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.30, yPercentage: 0.23 }, { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.30, yPercentage: 0.13 }, - { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.34, yPercentage: 0.81 }, - { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.38, yPercentage: 0.81 }, - { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.42, yPercentage: 0.81 }, + { name: 'blocks', id: 'jumpPlatform', class: SpawnPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.34, yPercentage: 0.81 }, + { name: 'blocks', id: 'jumpPlatform', class: SpawnPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.38, yPercentage: 0.81 }, + { name: 'blocks', id: 'jumpPlatform', class: SpawnPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.42, yPercentage: 0.81 }, { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.38, yPercentage: 0.57 }, { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.38, yPercentage: 0.47 }, { name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.cobblestone, xPercentage: 0.38, yPercentage: 0.37 }, @@ -913,6 +920,9 @@ const GameSetup = { { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.409, yPercentage: 0.7 }, { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.295, yPercentage: 0.46 }, + { name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: this.assets.enemies.magicBeam, xPercentage: 0.529, yPercentage: 0.61 }, + { name: 'chocoFrog', id: 'chocoFrog', class: ChocoFrog, data: this.assets.enemies.chocoFrog, xPercentage: 0.25, yPercentage: 0.3 }, + { name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: this.assets.enemies.magicBeam, xPercentage: 0.623, yPercentage: 0.72 }, { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.656, yPercentage: 0.46 }, diff --git a/assets/js/platformer3x/SpawnPlatform.js b/assets/js/platformer3x/SpawnPlatform.js index ec84a5a0..55c8da3c 100644 --- a/assets/js/platformer3x/SpawnPlatform.js +++ b/assets/js/platformer3x/SpawnPlatform.js @@ -19,7 +19,7 @@ export class SpawnPlatform extends GameObject { update() { // .log(this.platformY); this.canvas.style.visibility = 'hidden'; - if (GameEnv.destroyedMushroom === true) { + if (GameEnv.destroyedChocoFrog === true) { this.canvas.style.visibility = 'visible'; } } diff --git a/images/platformer/platforms/Chocolatefrog.jpg b/images/platformer/platforms/Chocolatefrog.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b905afb8d3cb56906b83bdf34f607c1f06bf02f1 GIT binary patch literal 8474 zcmaKRWmKF?)9qlvEf5GkXmA)vaCf&5EF|avgALB$!QCyu;O=fANU#t*xI;o9xcdNe zbI$jk_q#vtxzFletGk}syQ;ePk6NpBlob@7(gOhc@-kX_T0#am004mW&;0uLkXF-D zvc?7gQ0fMeNH)Q_YfmflS;xJa;LhgQtYvWZGG{}};f&sryhF!6W%Lq`?EpOE94Rg| zWcm0TUK$&L-6M`%C-I+c(Twpux-}EeN-D%Xe&y(SH!B({vAyyRZ6%J2Wh;JJ9>Z&~ z{Z^hC%wCy=U>&bQnHP%-s~3dJVGR#niZJ{+kd{nm;+!`&kA1+We*|pEo*kw z(yRX*lo4Gr>yGpACh}t11j_|Imb>vF$jgBdbMhWA!t-%D*}nGDy+!VeysX1feTO}9 z5bo0QlBz_D3O&rE%uim!8u!^KHh}c)o=*gqhY)}Pv0InMC5SIj<+jYU;BxN0sJTf< zP>(SId6JMF!cYPQ08-XFdbC=DR)4AfTantUOtgWE~&EYEimzwjC<*= zem3p#=(6*+Rk6SAW0iYK9uQeG`dGiwNFd&p-ROcn&OgEmnG99`*24VP__k9YaUx$7m4EnN6|fF z^`{ppaw^#g6ICPk&T&Qidvg*}m9Vj^5d-QT5kJ+3RH8%~J`IR?#PA0fX$KWnTuOe4 zbAJ0qX+JLVfj5h0^V@bpS`b|(&jM)8mJos+DY_uMeI48s((iXb4V6TRd`oBX8&>jy z$uS@_do#Bh=v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q4xirqLvNR4eDwGbpp!1767uUn^`~{|1z-sjZjw?QFe57Gjp^6E6a&9{Ndn+KrBUM z Date: Mon, 20 May 2024 13:03:24 -0700 Subject: [PATCH 02/13] fix idea box back to before --- assets/js/platformer3x/JumpPlatform.js | 41 +++++++------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/assets/js/platformer3x/JumpPlatform.js b/assets/js/platformer3x/JumpPlatform.js index f4396d1a..cbcbd8d3 100644 --- a/assets/js/platformer3x/JumpPlatform.js +++ b/assets/js/platformer3x/JumpPlatform.js @@ -1,4 +1,3 @@ - import GameControl from './GameControl.js'; import GameEnv from './GameEnv.js'; import GameObject from './GameObject.js'; @@ -9,34 +8,17 @@ export class JumpPlatform extends GameObject { this.platformX = xPercentage * GameEnv.innerWidth; this.platformY = yPercentage; this.data = data; + //integration notes: + //currently there are two variables each for the x and y position of the platform + //this is because two people fixed the same issue independently + //this may need to be returned to RIGHT NOW this.name = name; - this.relativeX = 0; //used for the item block's spritesheet. - this.direction = 1; - this.speed = 1; - this.minBottom = 150; // Minimum bottom position for the platform - this.maxBottom = 300; // Maximum bottom position for the platform - - + this.relativeX = ""; //used for the item block's spritesheet. } // Required, but no update action update() { this.collisionChecks(); - this.movePlatform(); - } - - movePlatform() { - let currentPosition = parseInt(this.canvas.style.bottom) || 0; - - if (currentPosition >= this.maxBottom) { - this.direction = -1; - } else if (currentPosition <= this.minBottom) { - this.direction = 1; - } - - this.canvas.style.bottom = currentPosition + this.direction * this.speed + 'px'; - this.relativeX += this.direction * this.speed; - this.draw(); } collisionAction() { @@ -44,7 +26,7 @@ export class JumpPlatform extends GameObject { if (this.collisionData.touchPoints.other.id === "player" && this.name === "itemBlock") { if (this.relativeX === 0 || this.relativeX === this.canvas.width) { if (this.relativeX === 0) { - GameControl.startRandomEvent(); + GameControl.startRandomEvent("game"); //console.log("randomEventtriggered", GameControl.randomEventId); }; this.relativeX = -1 * this.canvas.width; @@ -53,7 +35,7 @@ export class JumpPlatform extends GameObject { } } } - + // Set platform position size() { // Formula for Height should be on constant ratio, using a proportion of 832 @@ -75,15 +57,14 @@ export class JumpPlatform extends GameObject { this.canvas.style.height = `${scaledHeight}px`; this.canvas.style.position = 'absolute'; this.canvas.style.left = `${platformX}px`; - this.canvas.style.bottom = `${platformY}px`; + this.canvas.style.top = `${platformY}px`; + } // Draw position is always 0,0 draw() { - this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.ctx.drawImage(this.image, 0, 0, this.canvas.width / this.data.widthRatio, this.canvas.height / this.data.heightRatio); + this.ctx.drawImage(this.image, this.relativeX, 0, this.canvas.width / this.data.widthRatio, this.canvas.height / this.data.heightRatio); } - } -export default JumpPlatform; +export default JumpPlatform; \ No newline at end of file From 207f7572d756c7be66eddf9195c4e1b4111dd5ea Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 13:37:19 -0700 Subject: [PATCH 03/13] get rid of duplicate magic beam --- assets/js/platformer3x/GameSetup.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 6f13c089..3e7de465 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -985,7 +985,6 @@ const GameSetup = { { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.409, yPercentage: 0.7 }, { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.295, yPercentage: 0.46 }, - { name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: this.assets.enemies.magicBeam, xPercentage: 0.529, yPercentage: 0.61 }, { name: 'chocoFrog', id: 'chocoFrog', class: ChocoFrog, data: this.assets.enemies.chocoFrog, xPercentage: 0.25, yPercentage: 0.3 }, { name: 'magicBeam', id: 'magicBeam', class: MagicBeam, data: this.assets.enemies.magicBeam, xPercentage: 0.623, yPercentage: 0.72 }, From 612aa16787494813c81e7940bcd6252c9cc192b6 Mon Sep 17 00:00:00 2001 From: kaylale124 Date: Mon, 20 May 2024 13:38:32 -0700 Subject: [PATCH 04/13] new playermini file --- assets/js/platformer3x/PlayerMiniHogwarts.js | 152 +++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 assets/js/platformer3x/PlayerMiniHogwarts.js diff --git a/assets/js/platformer3x/PlayerMiniHogwarts.js b/assets/js/platformer3x/PlayerMiniHogwarts.js new file mode 100644 index 00000000..e12ffcea --- /dev/null +++ b/assets/js/platformer3x/PlayerMiniHogwarts.js @@ -0,0 +1,152 @@ +import GameEnv from './GameEnv.js'; +import PlayerBase from './PlayerBase.js'; +import GameControl from './GameControl.js'; + +/** + * @class PlayerHills class + * @description PlayerHills.js key objective is to eent the user-controlled character in the game. + * + * The Player class extends the Character class, which in turn extends the GameObject class. + * Animations and events are activated by key presses, collisions, and gravity. + * WASD keys are used by user to control The Player object. + * + * @extends PlayerBase + */ +export class PlayerMiniHogwarts extends PlayerBase { + + /** GameObject instantiation: constructor for PlayerHills object + * @extends Character + * @param {HTMLCanvasElement} canvas - The canvas element to draw the player on. + * @param {HTMLImageElement} image - The image to draw the player with. + * @param {Object} data - The data object containing the player's properties. + */ + constructor(canvas, image, data) { + super(canvas, image, data); + const scaledHeight = GameEnv.innerHeight * (100 / 832); + const tubeX = .01 * GameEnv.innerWidth; + this.setX(tubeX); + this.hillsStart = true; + + // Goomba variables, deprecate? + this.timer = false; + GameEnv.invincible = false; // Player is not invincible + } + + /** + * @override + * gameLoop helper: Update Player jump height, replaces PlayerBase updateJump using settings from GameEnv + */ + updateJump() { + let jumpHeightFactor; + if (GameEnv.difficulty === "easy") { + jumpHeightFactor = 0.50; + } else if (GameEnv.difficulty === "normal") { + jumpHeightFactor = 0.40; + } else { + jumpHeightFactor = 0.30; + } + this.setY(this.y - (this.bottom * jumpHeightFactor)); + } + update(){ + super.update(); + if (this.hillsStart) { + this.setY(0); + this.hillsStart = false; + } + } + /** + * @override + * gameLoop: Watch for Player collision events + */ + handleCollisionStart() { + super.handleCollisionStart(); // calls the super class method + // adds additional collision events + this.handleCollisionEvent("tubeU"); + this.handleCollisionEvent("goomba"); + this.handleCollisionEvent("mushroom"); + + } + + /** + * @override + * gameloop: Handles additional Player reaction / state updates to the collision for game level + */ + handlePlayerReaction() { + super.handlePlayerReaction(); // calls the super class method + // handles additional player reactions + switch (this.state.collision) { + case "tubeU": + // 1. Caught in tube + + if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) { + // Position player in the center of the tube + this.x = this.collisionData.newX; + // Using natural gravity wait for player to reach floor + if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) { + // Force end of level condition + //this.x = GameEnv.innerWidth + 1; + GameControl.transitionToLevel(GameEnv.levels[6]) + return + } + + // 2. Collision between player right and tube + } else if (this.collisionData.touchPoints.this.right) { + this.state.movement.right = false; + this.state.movement.left = true; + // 3. Collision between player left and tube + } else if (this.collisionData.touchPoints.this.left) { + this.state.movement.left = false; + this.state.movement.right = true; + } + + break; + case "goomba": // Note: Goomba.js and Player.js could be refactored + // 1. Player jumps on goomba, interaction with Goomba.js + if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom && this.state.isDying == false) { + // GoombaBounce deals with player.js and goomba.js + if (GameEnv.goombaBounce === true) { + GameEnv.goombaBounce = false; + this.y = this.y - 100; + } + if (GameEnv.goombaBounce1 === true) { + GameEnv.goombaBounce1 = false; + this.y = this.y - 250 + } + // 2. Player touches goomba sides of goomba + } else if (this.collisionData.touchPoints.this.right || this.collisionData.touchPoints.this.left) { + if (GameEnv.difficulty === "normal" || GameEnv.difficulty === "hard") { + if (this.state.isDying == false) { + this.state.isDying = true; + this.canvas.style.transition = "transform 0.5s"; + this.canvas.style.transform = "rotate(-90deg) translate(-26px, 0%)"; + GameEnv.playSound("PlayerDeath"); + setTimeout(async() => { + await GameControl.transitionToLevel(GameEnv.levels[GameEnv.levels.indexOf(GameEnv.currentLevel)]); + }, 900); + } + } else if (GameEnv.difficulty === "easy" && this.collisionData.touchPoints.this.right) { + this.x -= 10; + } else if (GameEnv.difficulty === "easy" && this.collisionData.touchPoints.this.left) { + this.x += 10; + } + + } + break; + case "mushroom": // + // Player touches mushroom + if (GameEnv.destroyedMushroom === false) { + GameEnv.destroyedMushroom = true; + this.canvas.style.filter = 'invert(1)'; + // Invert state lasts for 2 seconds + setTimeout(() => { + this.canvas.style.filter = 'invert(0)'; + }, 2000); // 2000 milliseconds = 2 seconds + } + break; + } + + } + +} + +export default PlayerMiniHogwarts; \ No newline at end of file From 777cbd0b7b5f858451d14394d9f7dc859d22e95a Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 13:55:07 -0700 Subject: [PATCH 05/13] add mini tube to quidditch --- assets/js/platformer3x/GameSetup.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 3e7de465..188267f2 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -11,6 +11,7 @@ import JumpPlatform from './JumpPlatform.js'; import PlayerHills from './PlayerHills.js'; import PlayerWinter from './PlayerWinter.js'; import PlayerMini from './PlayerMini.js'; +import PlayerMiniHogwarts from './PlayerMiniHogwarts.js'; import PlayerQuidditch from './PlayerQuidditch.js'; import Goomba from './Goomba.js'; import FlyingGoomba from './FlyingGoomba.js'; @@ -995,6 +996,7 @@ const GameSetup = { { name: 'harry', id: 'player', class: PlayerQuidditch, data: this.assets.players.harry }, { name: 'tube', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.65 }, + { name: 'tubeU', id: 'minifinishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: .75, yPercentage: 0.65 }, { name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: this.assets.transitions.waterEnd }, ]; @@ -1054,7 +1056,7 @@ const GameSetup = { { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.799, yPercentage: 0.81 }, - { name: 'harry', id: 'player', class: PlayerMini, data: this.assets.players.harry }, + { name: 'harry', id: 'player', class: PlayerMiniHogwarts, data: this.assets.players.harry }, { name: 'tubeD', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeD, xPercentage: 0, yPercentage: 0.052 }, { name: 'tubeU', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: 0.85, yPercentage: 0.646 }, ]; From 4aacf7981c80c4931fdedd423ea2756a918fc1ff Mon Sep 17 00:00:00 2001 From: vibha1019 <114361148+vibha1019@users.noreply.github.com> Date: Mon, 20 May 2024 17:37:18 -0700 Subject: [PATCH 06/13] sorta fixed the tube stuff --- assets/js/platformer3x/PlayerMiniHogwarts.js | 14 +++--- assets/js/platformer3x/PlayerQuidditch.js | 45 ++++++++++++++------ 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/assets/js/platformer3x/PlayerMiniHogwarts.js b/assets/js/platformer3x/PlayerMiniHogwarts.js index e12ffcea..bf4c9cfe 100644 --- a/assets/js/platformer3x/PlayerMiniHogwarts.js +++ b/assets/js/platformer3x/PlayerMiniHogwarts.js @@ -23,8 +23,8 @@ export class PlayerMiniHogwarts extends PlayerBase { constructor(canvas, image, data) { super(canvas, image, data); const scaledHeight = GameEnv.innerHeight * (100 / 832); - const tubeX = .01 * GameEnv.innerWidth; - this.setX(tubeX); + const finishlineX = .01 * GameEnv.innerWidth; + this.setX(finishlineX); this.hillsStart = true; // Goomba variables, deprecate? @@ -61,7 +61,7 @@ export class PlayerMiniHogwarts extends PlayerBase { handleCollisionStart() { super.handleCollisionStart(); // calls the super class method // adds additional collision events - this.handleCollisionEvent("tubeU"); + this.handleCollisionEvent("finishline"); this.handleCollisionEvent("goomba"); this.handleCollisionEvent("mushroom"); @@ -75,8 +75,8 @@ export class PlayerMiniHogwarts extends PlayerBase { super.handlePlayerReaction(); // calls the super class method // handles additional player reactions switch (this.state.collision) { - case "tubeU": - // 1. Caught in tube + case "finishline": + // 1. Caught in finishline if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) { // Position player in the center of the tube @@ -89,11 +89,11 @@ export class PlayerMiniHogwarts extends PlayerBase { return } - // 2. Collision between player right and tube + // 2. Collision between player right and finishline } else if (this.collisionData.touchPoints.this.right) { this.state.movement.right = false; this.state.movement.left = true; - // 3. Collision between player left and tube + // 3. Collision between player left and finishline } else if (this.collisionData.touchPoints.this.left) { this.state.movement.left = false; this.state.movement.right = true; diff --git a/assets/js/platformer3x/PlayerQuidditch.js b/assets/js/platformer3x/PlayerQuidditch.js index fb81c068..24bdd0e8 100644 --- a/assets/js/platformer3x/PlayerQuidditch.js +++ b/assets/js/platformer3x/PlayerQuidditch.js @@ -63,26 +63,43 @@ export class PlayerQuidditch extends PlayerBase { super.handlePlayerReaction(); // calls the super class method // handles additional player reactions switch (this.state.collision) { - case "finishline": + case "minifinishline": // 1. Caught in finishline if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) { - // Position player in the center of the finishline + // Position player in the center of the finishline this.x = this.collisionData.newX; // Using natural gravity wait for player to reach floor if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) { // Force end of level condition - this.x = GameEnv.innerWidth + 1; + // this.x = GameEnv.innerWidth + 1; + GameControl.transitionToLevel(GameEnv.levels[7]); + return; } - // 2. Collision between player right and finishline - } else if (this.collisionData.touchPoints.this.right) { - this.state.movement.right = false; - this.state.movement.left = true; - // 3. Collision between player left and finishline - } else if (this.collisionData.touchPoints.this.left) { - this.state.movement.left = false; - this.state.movement.right = true; } + break; + + case "finishline": + // 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; + // Using natural gravity wait for player to reach floor + if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) { + // Force end of level condition + //this.x = GameEnv.innerWidth + 1; + GameControl.transitionToLevel(GameEnv.levels[8]) + } + // 2. Collision between player right and finishline + } else if (this.collisionData.touchPoints.this.right) { + this.state.movement.right = false; + this.state.movement.left = true; + // 3. Collision between player left and finishline + } else if (this.collisionData.touchPoints.this.left) { + this.state.movement.left = false; + this.state.movement.right = true; + } break; + case "draco": // Note: Goomba.js and Player.js could be refactored // 1. Player jumps on goomba, interaction with Goomba.js if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom && this.state.isDying == false) { @@ -93,7 +110,7 @@ export class PlayerQuidditch extends PlayerBase { } if (GameEnv.goombaBounce1 === true) { GameEnv.goombaBounce1 = false; - this.y = this.y - 250 + this.y = this.y - 250; } // 2. Player touches goomba sides of goomba } else if (this.collisionData.touchPoints.this.right || this.collisionData.touchPoints.this.left) { @@ -110,12 +127,12 @@ export class PlayerQuidditch extends PlayerBase { } else if (GameEnv.difficulty === "easy" && this.collisionData.touchPoints.this.right) { this.x -= 10; } else if (GameEnv.difficulty === "easy" && this.collisionData.touchPoints.this.left) { - this.x += 10; + this.x += 10; } - } break; } + } From 2789f28ec5d22370308c3d40900de7956146aa15 Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 23:26:31 -0700 Subject: [PATCH 07/13] shift tubes down --- assets/js/platformer3x/GameSetup.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 188267f2..c79133e6 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -995,8 +995,8 @@ const GameSetup = { { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.700, yPercentage: 0.46 }, { name: 'harry', id: 'player', class: PlayerQuidditch, data: this.assets.players.harry }, - { name: 'tube', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.65 }, - { name: 'tubeU', id: 'minifinishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: .75, yPercentage: 0.65 }, + { name: 'tube', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.7 }, + { name: 'tubeU', id: 'minifinishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: .75, yPercentage: 0.7 }, { name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: this.assets.transitions.waterEnd }, ]; @@ -1058,7 +1058,7 @@ const GameSetup = { { name: 'harry', id: 'player', class: PlayerMiniHogwarts, data: this.assets.players.harry }, { name: 'tubeD', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeD, xPercentage: 0, yPercentage: 0.052 }, - { name: 'tubeU', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: 0.85, yPercentage: 0.646 }, + { name: 'tubeU', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: 0.85, yPercentage: 0.7 }, ]; // miniHogwarts Game Level added to the GameEnv ... From 629ae55b641f82ea46ad598455dd5fc34b3efe7e Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 23:40:58 -0700 Subject: [PATCH 08/13] comment out draco that interferes with tubes --- assets/js/platformer3x/GameSetup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index c79133e6..a0c82e88 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -975,7 +975,7 @@ const GameSetup = { { name: 'draco', id: 'draco', class: Draco, data: this.assets.enemies.draco, xPercentage: 0.3, minPosition: 0.05, difficulties: ["normal", "hard", "impossible"] }, { name: 'draco', id: 'draco', class: Draco, data: this.assets.enemies.draco, xPercentage: 0.5, minPosition: 0.3, difficulties: ["normal", "hard", "impossible"] }, - { name: 'draco', id: 'draco', class: Draco, data: this.assets.enemies.draco, xPercentage: 0.75, minPosition: 0.5, difficulties: ["normal", "hard", "impossible"] }, //this special name is used for random event 2 to make sure that only one of the Goombas ends the random event + /**{ name: 'draco', id: 'draco', class: Draco, data: this.assets.enemies.draco, xPercentage: 0.75, minPosition: 0.5, difficulties: ["normal", "hard", "impossible"] }, //this special name is used for random event 2 to make sure that only one of the Goombas ends the random event */ { name: 'dementor', id: 'dementor', class: Dementor, data: this.assets.enemies.dementor, xPercentage: 0.5, minPosition: 0.05 }, { name: 'dementor', id: 'dementor', class: Dementor, data: this.assets.enemies.dementor, xPercentage: 0.9, minPosition: 0.5 }, @@ -996,7 +996,7 @@ const GameSetup = { { name: 'harry', id: 'player', class: PlayerQuidditch, data: this.assets.players.harry }, { name: 'tube', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tube, xPercentage: 0.85, yPercentage: 0.7 }, - { name: 'tubeU', id: 'minifinishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: .75, yPercentage: 0.7 }, + { name: 'tubeU', id: 'minifinishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: 0.75, yPercentage: 0.7 }, { name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: this.assets.transitions.waterEnd }, ]; From 9ac5cf01281bd64054e4bd327e11fcd33db80535 Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 23:45:44 -0700 Subject: [PATCH 09/13] add playerquidditch collision --- assets/js/platformer3x/PlayerQuidditch.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/assets/js/platformer3x/PlayerQuidditch.js b/assets/js/platformer3x/PlayerQuidditch.js index 24bdd0e8..3ab044ee 100644 --- a/assets/js/platformer3x/PlayerQuidditch.js +++ b/assets/js/platformer3x/PlayerQuidditch.js @@ -66,18 +66,25 @@ export class PlayerQuidditch extends PlayerBase { case "minifinishline": // 1. Caught in finishline if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) { - // Position player in the center of the finishline + // Position player in the center of the finishline this.x = this.collisionData.newX; // Using natural gravity wait for player to reach floor if (Math.abs(this.y - this.bottom) <= GameEnv.gravity) { // Force end of level condition // this.x = GameEnv.innerWidth + 1; - GameControl.transitionToLevel(GameEnv.levels[7]); - return; + GameControl.transitionToLevel(GameEnv.levels[7]) + return } + // 2. Collision between player right and finishline + } else if (this.collisionData.touchPoints.this.right) { + this.state.movement.right = false; + this.state.movement.left = true; + // 3. Collision between player left and finishline + } else if (this.collisionData.touchPoints.this.left) { + this.state.movement.left = false; + this.state.movement.right = true; } - break; - + break; case "finishline": // 1. Caught in finishline if (this.collisionData.touchPoints.this.top && this.collisionData.touchPoints.other.bottom) { From ae90925ee181a5af0b7490b95b7ab9e81dbcae3b Mon Sep 17 00:00:00 2001 From: abbymanalo Date: Mon, 20 May 2024 23:58:04 -0700 Subject: [PATCH 10/13] adjust snitch placements --- assets/js/platformer3x/GameSetup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index a0c82e88..547e4e1d 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -1053,7 +1053,7 @@ const GameSetup = { { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.43, yPercentage: 0.82 }, { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.47, yPercentage: 0.24 }, - { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.799, yPercentage: 0.81 }, + { name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.85, yPercentage: 0.81 }, { name: 'harry', id: 'player', class: PlayerMiniHogwarts, data: this.assets.players.harry }, From a249106f3b529dbc8b0cb75ca56c0b96dc3e8c84 Mon Sep 17 00:00:00 2001 From: kaylale124 Date: Tue, 21 May 2024 11:41:40 -0700 Subject: [PATCH 11/13] Rename files --- assets/js/platformer3x/BossItem.js | 2 +- .../{Cerberus.js => EnemyCerberus.js} | 0 .../platformer3x/{Draco.js => EnemyDraco.js} | 0 .../{Goomba.js => EnemyGoomba.js} | 0 .../{Penguin.js => EnemyPenguin.js} | 0 .../{Snowman.js => EnemySnowman.js} | 0 .../{Dementor.js => FlyingDementor.js} | 0 .../{Dragon.js => FlyingDragon.js} | 0 .../{Jellyfish.js => FlyingJellyfish.js} | 0 .../js/platformer3x/{Owl.js => FlyingOwl.js} | 0 assets/js/platformer3x/GameSetup.js | 26 +++++++++---------- ...lyingIsland.js => PlatformFlyingIsland.js} | 0 .../{JumpPlatform.js => PlatformJump.js} | 0 .../{MovingPlatform.js => PlatformMoving.js} | 0 .../{SpawnPlatform.js => PlatformSpawn.js} | 0 15 files changed, 14 insertions(+), 14 deletions(-) rename assets/js/platformer3x/{Cerberus.js => EnemyCerberus.js} (100%) rename assets/js/platformer3x/{Draco.js => EnemyDraco.js} (100%) rename assets/js/platformer3x/{Goomba.js => EnemyGoomba.js} (100%) rename assets/js/platformer3x/{Penguin.js => EnemyPenguin.js} (100%) rename assets/js/platformer3x/{Snowman.js => EnemySnowman.js} (100%) rename assets/js/platformer3x/{Dementor.js => FlyingDementor.js} (100%) rename assets/js/platformer3x/{Dragon.js => FlyingDragon.js} (100%) rename assets/js/platformer3x/{Jellyfish.js => FlyingJellyfish.js} (100%) rename assets/js/platformer3x/{Owl.js => FlyingOwl.js} (100%) rename assets/js/platformer3x/{FlyingIsland.js => PlatformFlyingIsland.js} (100%) rename assets/js/platformer3x/{JumpPlatform.js => PlatformJump.js} (100%) rename assets/js/platformer3x/{MovingPlatform.js => PlatformMoving.js} (100%) rename assets/js/platformer3x/{SpawnPlatform.js => PlatformSpawn.js} (100%) diff --git a/assets/js/platformer3x/BossItem.js b/assets/js/platformer3x/BossItem.js index 577bb6ac..60e65e0c 100644 --- a/assets/js/platformer3x/BossItem.js +++ b/assets/js/platformer3x/BossItem.js @@ -1,6 +1,6 @@ import GameControl from './GameControl.js'; import GameEnv from './GameEnv.js'; -import JumpPlatform from './JumpPlatform.js'; +import JumpPlatform from './PlatformJump.js'; export class BossItem extends JumpPlatform { constructor(canvas, image, data, xPercentage, yPercentage, name) { diff --git a/assets/js/platformer3x/Cerberus.js b/assets/js/platformer3x/EnemyCerberus.js similarity index 100% rename from assets/js/platformer3x/Cerberus.js rename to assets/js/platformer3x/EnemyCerberus.js diff --git a/assets/js/platformer3x/Draco.js b/assets/js/platformer3x/EnemyDraco.js similarity index 100% rename from assets/js/platformer3x/Draco.js rename to assets/js/platformer3x/EnemyDraco.js diff --git a/assets/js/platformer3x/Goomba.js b/assets/js/platformer3x/EnemyGoomba.js similarity index 100% rename from assets/js/platformer3x/Goomba.js rename to assets/js/platformer3x/EnemyGoomba.js diff --git a/assets/js/platformer3x/Penguin.js b/assets/js/platformer3x/EnemyPenguin.js similarity index 100% rename from assets/js/platformer3x/Penguin.js rename to assets/js/platformer3x/EnemyPenguin.js diff --git a/assets/js/platformer3x/Snowman.js b/assets/js/platformer3x/EnemySnowman.js similarity index 100% rename from assets/js/platformer3x/Snowman.js rename to assets/js/platformer3x/EnemySnowman.js diff --git a/assets/js/platformer3x/Dementor.js b/assets/js/platformer3x/FlyingDementor.js similarity index 100% rename from assets/js/platformer3x/Dementor.js rename to assets/js/platformer3x/FlyingDementor.js diff --git a/assets/js/platformer3x/Dragon.js b/assets/js/platformer3x/FlyingDragon.js similarity index 100% rename from assets/js/platformer3x/Dragon.js rename to assets/js/platformer3x/FlyingDragon.js diff --git a/assets/js/platformer3x/Jellyfish.js b/assets/js/platformer3x/FlyingJellyfish.js similarity index 100% rename from assets/js/platformer3x/Jellyfish.js rename to assets/js/platformer3x/FlyingJellyfish.js diff --git a/assets/js/platformer3x/Owl.js b/assets/js/platformer3x/FlyingOwl.js similarity index 100% rename from assets/js/platformer3x/Owl.js rename to assets/js/platformer3x/FlyingOwl.js diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 3e7de465..d707a6c2 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -7,36 +7,36 @@ import BackgroundParallax from './BackgroundParallax.js'; import BackgroundTransitions from './BackgroundTransitions.js'; import BackgroundSnow from './BackgroundSnow.js'; import Platform from './Platform.js'; -import JumpPlatform from './JumpPlatform.js'; +import JumpPlatform from './PlatformJump.js'; import PlayerHills from './PlayerHills.js'; import PlayerWinter from './PlayerWinter.js'; import PlayerMini from './PlayerMini.js'; import PlayerQuidditch from './PlayerQuidditch.js'; -import Goomba from './Goomba.js'; +import Goomba from './EnemyGoomba.js'; import FlyingGoomba from './FlyingGoomba.js'; import BlockPlatform from './BlockPlatform.js'; -import SpawnPlatform from './SpawnPlatform.js'; -import MovingPlatform from './MovingPlatform.js' +import SpawnPlatform from './PlatformSpawn.js'; +import MovingPlatform from './PlatformMoving.js' import Mushroom from './Mushroom.js'; import MagicBeam from './MagicBeam.js'; import ChocoFrog from './ChocoFrog.js'; import Coin from './Coin.js'; import GameControl from './GameControl.js'; -import Owl from './Owl.js'; -import Snowman from './Snowman.js'; -import Cerberus from './Cerberus.js'; +import Owl from './FlyingOwl.js'; +import Snowman from './EnemySnowman.js'; +import Cerberus from './EnemyCerberus.js'; import PlayerGreece from './PlayerGreece.js'; import FinishLine from './FinishLine.js'; import Lava from './Lava.js'; -import Dragon from './Dragon.js'; +import Dragon from './FlyingDragon.js'; import Star from './Star.js'; -import Dementor from './Dementor.js'; -import Draco from './Draco.js'; +import Dementor from './FlyingDementor.js'; +import Draco from './EnemyDraco.js'; import Boss from './Boss.js'; -import Jellyfish from './Jellyfish.js'; -import Penguin from './Penguin.js'; +import Jellyfish from './FlyingJellyfish.js'; +import Penguin from './EnemyPenguin.js'; import PlayerIce from './PlayerIce.js'; -import FlyingIsland from './FlyingIsland.js'; +import FlyingIsland from './PlatformFlyingIsland.js'; import PlayerBaseOneD from './PlayerBaseOneD.js'; import PlayerZombie from './PlayerZombie.js'; import BossItem from './BossItem.js'; diff --git a/assets/js/platformer3x/FlyingIsland.js b/assets/js/platformer3x/PlatformFlyingIsland.js similarity index 100% rename from assets/js/platformer3x/FlyingIsland.js rename to assets/js/platformer3x/PlatformFlyingIsland.js diff --git a/assets/js/platformer3x/JumpPlatform.js b/assets/js/platformer3x/PlatformJump.js similarity index 100% rename from assets/js/platformer3x/JumpPlatform.js rename to assets/js/platformer3x/PlatformJump.js diff --git a/assets/js/platformer3x/MovingPlatform.js b/assets/js/platformer3x/PlatformMoving.js similarity index 100% rename from assets/js/platformer3x/MovingPlatform.js rename to assets/js/platformer3x/PlatformMoving.js diff --git a/assets/js/platformer3x/SpawnPlatform.js b/assets/js/platformer3x/PlatformSpawn.js similarity index 100% rename from assets/js/platformer3x/SpawnPlatform.js rename to assets/js/platformer3x/PlatformSpawn.js From fa4a06fca8429a6b04f6c744305e5bd0bdc4457f Mon Sep 17 00:00:00 2001 From: kaylale124 Date: Tue, 21 May 2024 12:50:53 -0700 Subject: [PATCH 12/13] change PlatformJump to orginal name --- assets/js/platformer3x/BossItem.js | 2 +- assets/js/platformer3x/GameSetup.js | 2 +- assets/js/platformer3x/{PlatformJump.js => JumpPlatform.js} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename assets/js/platformer3x/{PlatformJump.js => JumpPlatform.js} (100%) diff --git a/assets/js/platformer3x/BossItem.js b/assets/js/platformer3x/BossItem.js index 60e65e0c..577bb6ac 100644 --- a/assets/js/platformer3x/BossItem.js +++ b/assets/js/platformer3x/BossItem.js @@ -1,6 +1,6 @@ import GameControl from './GameControl.js'; import GameEnv from './GameEnv.js'; -import JumpPlatform from './PlatformJump.js'; +import JumpPlatform from './JumpPlatform.js'; export class BossItem extends JumpPlatform { constructor(canvas, image, data, xPercentage, yPercentage, name) { diff --git a/assets/js/platformer3x/GameSetup.js b/assets/js/platformer3x/GameSetup.js index 6c31dfd8..fc290a10 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -7,7 +7,7 @@ import BackgroundParallax from './BackgroundParallax.js'; import BackgroundTransitions from './BackgroundTransitions.js'; import BackgroundSnow from './BackgroundSnow.js'; import Platform from './Platform.js'; -import JumpPlatform from './PlatformJump.js'; +import JumpPlatform from './JumpPlatform.js'; import PlayerHills from './PlayerHills.js'; import PlayerWinter from './PlayerWinter.js'; import PlayerMini from './PlayerMini.js'; diff --git a/assets/js/platformer3x/PlatformJump.js b/assets/js/platformer3x/JumpPlatform.js similarity index 100% rename from assets/js/platformer3x/PlatformJump.js rename to assets/js/platformer3x/JumpPlatform.js From f5256bf23fda153c1229d235f19c532e3e8d312d Mon Sep 17 00:00:00 2001 From: kaylale124 Date: Tue, 21 May 2024 12:57:33 -0700 Subject: [PATCH 13/13] resolve conflicts --- assets/js/platformer3x/JumpPlatform.js | 37 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/assets/js/platformer3x/JumpPlatform.js b/assets/js/platformer3x/JumpPlatform.js index cbcbd8d3..39309e7d 100644 --- a/assets/js/platformer3x/JumpPlatform.js +++ b/assets/js/platformer3x/JumpPlatform.js @@ -1,3 +1,5 @@ + + import GameControl from './GameControl.js'; import GameEnv from './GameEnv.js'; import GameObject from './GameObject.js'; @@ -8,17 +10,33 @@ export class JumpPlatform extends GameObject { this.platformX = xPercentage * GameEnv.innerWidth; this.platformY = yPercentage; this.data = data; - //integration notes: - //currently there are two variables each for the x and y position of the platform - //this is because two people fixed the same issue independently - //this may need to be returned to RIGHT NOW this.name = name; this.relativeX = ""; //used for the item block's spritesheet. + this.direction = 1; + this.speed = 1; + this.minBottom = 150; // Minimum bottom position for the platform + this.maxBottom = 300; // Maximum bottom position for the platform + + } // Required, but no update action update() { this.collisionChecks(); + //this.movePlatform(); it break the collision event, so I suggest to move this function to BlockPlaform + } + + movePlatform() { + let currentPosition = parseInt(this.canvas.style.bottom) || 0; + + if (currentPosition >= this.maxBottom) { + this.direction = -1; + } else if (currentPosition <= this.minBottom) { + this.direction = 1; + } + + this.canvas.style.bottom = currentPosition + this.direction * this.speed + 'px'; + this.relativeX += this.direction * this.speed; } collisionAction() { @@ -35,7 +53,7 @@ export class JumpPlatform extends GameObject { } } } - + // Set platform position size() { // Formula for Height should be on constant ratio, using a proportion of 832 @@ -57,14 +75,15 @@ export class JumpPlatform extends GameObject { this.canvas.style.height = `${scaledHeight}px`; this.canvas.style.position = 'absolute'; this.canvas.style.left = `${platformX}px`; - this.canvas.style.top = `${platformY}px`; - + this.canvas.style.bottom = `${platformY}px`; } // Draw position is always 0,0 draw() { - this.ctx.drawImage(this.image, this.relativeX, 0, this.canvas.width / this.data.widthRatio, this.canvas.height / this.data.heightRatio); + this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.ctx.drawImage(this.image, 0, 0, this.canvas.width / this.data.widthRatio, this.canvas.height / this.data.heightRatio); } + } -export default JumpPlatform; \ No newline at end of file +export default JumpPlatform;