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/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/GameEnv.js b/assets/js/platformer3x/GameEnv.js index e629e41f..f6a4d1f3 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 25c8c1eb..b168d1c1 100644 --- a/assets/js/platformer3x/GameSetup.js +++ b/assets/js/platformer3x/GameSetup.js @@ -11,31 +11,33 @@ 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 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 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'; @@ -552,6 +554,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, @@ -943,9 +951,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 }, @@ -967,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 }, @@ -978,6 +986,8 @@ 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: '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 }, @@ -985,7 +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: '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: 0.75, yPercentage: 0.7 }, { name: 'waterEnd', id: 'background', class: BackgroundTransitions, data: this.assets.transitions.waterEnd }, ]; @@ -1042,12 +1053,12 @@ 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: 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 }, + { name: 'tubeU', id: 'finishline', class: FinishLine, data: this.assets.obstacles.tubeU, xPercentage: 0.85, yPercentage: 0.7 }, ]; // miniHogwarts Game Level added to the GameEnv ... diff --git a/assets/js/platformer3x/JumpPlatform.js b/assets/js/platformer3x/JumpPlatform.js index aef6a9df..39309e7d 100644 --- a/assets/js/platformer3x/JumpPlatform.js +++ b/assets/js/platformer3x/JumpPlatform.js @@ -1,4 +1,5 @@ + import GameControl from './GameControl.js'; import GameEnv from './GameEnv.js'; import GameObject from './GameObject.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/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 97% rename from assets/js/platformer3x/SpawnPlatform.js rename to assets/js/platformer3x/PlatformSpawn.js index ec84a5a0..55c8da3c 100644 --- a/assets/js/platformer3x/SpawnPlatform.js +++ b/assets/js/platformer3x/PlatformSpawn.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/assets/js/platformer3x/PlayerMiniHogwarts.js b/assets/js/platformer3x/PlayerMiniHogwarts.js new file mode 100644 index 00000000..bf4c9cfe --- /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 finishlineX = .01 * GameEnv.innerWidth; + this.setX(finishlineX); + 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("finishline"); + 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 "finishline": + // 1. Caught in finishline + + 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 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 "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 diff --git a/assets/js/platformer3x/PlayerQuidditch.js b/assets/js/platformer3x/PlayerQuidditch.js index fb81c068..3ab044ee 100644 --- a/assets/js/platformer3x/PlayerQuidditch.js +++ b/assets/js/platformer3x/PlayerQuidditch.js @@ -63,7 +63,7 @@ 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 @@ -71,9 +71,11 @@ export class PlayerQuidditch extends PlayerBase { // 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 + // 2. Collision between player right and finishline } else if (this.collisionData.touchPoints.this.right) { this.state.movement.right = false; this.state.movement.left = true; @@ -83,6 +85,28 @@ export class PlayerQuidditch extends PlayerBase { 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 +117,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 +134,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; } + } diff --git a/images/platformer/platforms/Chocolatefrog.jpg b/images/platformer/platforms/Chocolatefrog.jpg new file mode 100644 index 00000000..b905afb8 Binary files /dev/null and b/images/platformer/platforms/Chocolatefrog.jpg differ