generated from nighthawkcoders/teacher_portfolio
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from kaylale124/main
Rename Files & Fix ? Box
- Loading branch information
Showing
19 changed files
with
331 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.