Skip to content

Commit

Permalink
Merge pull request #88 from kaylale124/main
Browse files Browse the repository at this point in the history
Rename Files & Fix ? Box
  • Loading branch information
kaylale124 authored May 21, 2024
2 parents 620976a + f5256bf commit 466dc46
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 28 deletions.
113 changes: 113 additions & 0 deletions assets/js/platformer3x/ChocoFrog.js
Original file line number Diff line number Diff line change
@@ -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;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions assets/js/platformer3x/GameEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
53 changes: 32 additions & 21 deletions assets/js/platformer3x/GameSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },

Expand All @@ -978,14 +986,17 @@ 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 },
{ name: 'coin', id: 'coin', class: Coin, data: this.assets.obstacles.snitch, xPercentage: 0.611, yPercentage: 0.46 },
{ 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 },
];

Expand Down Expand Up @@ -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 ...
Expand Down
1 change: 1 addition & 0 deletions assets/js/platformer3x/JumpPlatform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


import GameControl from './GameControl.js';
import GameEnv from './GameEnv.js';
import GameObject from './GameObject.js';
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Expand Down
Loading

0 comments on commit 466dc46

Please sign in to comment.