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 #62 from kaylale124/main
Team Level - Quidditch
- Loading branch information
Showing
4 changed files
with
257 additions
and
16 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,80 @@ | ||
import Character from './Character.js'; | ||
import FlyingGoomba from './FlyingGoomba.js'; | ||
import GameEnv from './GameEnv.js'; | ||
|
||
export class Dementor extends FlyingGoomba { | ||
|
||
// 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.yPercentage = yPercentage; | ||
|
||
//Initial Position of Goomba | ||
this.x = xPercentage * GameEnv.innerWidth; | ||
this.y = 0.4 * GameEnv.innerHeight; | ||
|
||
//Access in which a Goomba can travel | ||
this.minPosition = minPosition * GameEnv.innerWidth; | ||
this.maxPosition = this.x + xPercentage * GameEnv.innerWidth; | ||
|
||
this.immune = 0; | ||
|
||
//Define Speed of Enemy | ||
if (GameEnv.difficulty === "normal") { | ||
this.speed = this.speed; | ||
} else { | ||
this.speed = this.speed * 2; | ||
} | ||
} | ||
|
||
update() { | ||
super.update(); | ||
|
||
if (this.x <= this.minPosition || (this.x + this.canvasWidth >= this.maxPosition) || this.x > (GameEnv.innerWidth - 100) ) { | ||
this.speed = -this.speed; | ||
} | ||
|
||
if (this.speed < 0) { | ||
this.canvas.style.transform = 'scaleX(1)'; | ||
} else { | ||
this.canvas.style.transform = 'scaleX(-1)'; | ||
} | ||
|
||
this.dropGoomba(); | ||
|
||
// Every so often change direction | ||
if (Math.random() < 0.005) { | ||
this.speed = Math.random() < 0.5 ? -this.speed : this.speed; | ||
} | ||
|
||
//Chance for Goomba to turn Gold | ||
if (["normal","hard"].includes(GameEnv.difficulty)) { | ||
if (Math.random() < 0.00001) { | ||
this.canvas.style.filter = 'brightness(1000%)'; | ||
this.immune = 1; | ||
} | ||
} | ||
|
||
//Immunize Goomba & 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.canvas.style.transform = "rotate(180deg)" | ||
this.immune = 1; | ||
} | ||
|
||
// Move the enemy | ||
this.x -= this.speed; | ||
} | ||
|
||
// Player action on collisions | ||
} | ||
|
||
|
||
export default Dementor; |
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,59 @@ | ||
import Character from './Character.js'; | ||
import GameEnv from './GameEnv.js'; | ||
import GameControl from './GameControl.js'; | ||
import Enemy from './Enemy.js'; | ||
|
||
export class Draco extends Enemy { | ||
// 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 of Goomba | ||
this.x = xPercentage * GameEnv.innerWidth; | ||
|
||
//Access in which a Goomba can travel | ||
this.minPosition = minPosition * GameEnv.innerWidth; | ||
this.maxPosition = this.x + xPercentage * GameEnv.innerWidth; | ||
|
||
this.immune = 0; | ||
|
||
//Define Speed of Enemy | ||
if (["easy", "normal"].includes(GameEnv.difficulty)) { | ||
this.speed = this.speed * Math.floor(Math.random() * 1.5 + 2); | ||
} else if (GameEnv.difficulty === "hard") { | ||
this.speed = this.speed * Math.floor(Math.random() * 3 + 3); | ||
} else { | ||
this.speed = this.speed * 5 | ||
} | ||
} | ||
|
||
updateMovement(){ | ||
if (this.direction === "d") { | ||
this.speed = Math.abs(this.storeSpeed) | ||
} | ||
else if (this.direction === "a") { | ||
this.speed = -Math.abs(this.storeSpeed); | ||
} | ||
else if (this.direction === "idle") { | ||
this.speed = 0 | ||
} | ||
|
||
|
||
// Move the enemy\ | ||
this.x += this.speed; | ||
} | ||
|
||
update() { | ||
super.update(); | ||
super.checkBoundaries(); | ||
this.updateMovement(); | ||
} | ||
|
||
|
||
} | ||
|
||
export default Draco; |
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