Open Hypernova101 opened 1 month ago
Same as the Base file for Enemy, we can have a new base file for FlyingEnemy to clean up the code Before we create the Base file, we can see that the codes for the FlyingEnemy are not consistent from level to level Some of them just copy and paste all the code from FlyingGoomba.js and some of them choose to extend the FlyingGoomba
Both ways have repeated code segments that aren't necessary and are easier to confuse others (CSSE students for next year).
How to fix?:
And we will have a simple code for our flying enemy which is easier to read and more pleasing our eyes.
import FlyingEnemy from './FlyingEnemy.js';
export class FlyingGoomba extends FlyingEnemy {
// constructors sets up Character object
constructor(canvas, image, data, xPercentage, yPercentage, name, minPosition){
super(canvas, image, data, xPercentage, yPercentage, name, minPosition);
this.enemySpeed();
}
update() {
super.update();
}
}
export default FlyingGoomba;
Changes for Past Week
1. Cleaned Up Boss Level
The first thing we did this week was clean up GameSetup.js by editing the GameSetterBoss.js file. We removed some unused assets, cleaned up the overall look of the GameSetterBoss file, and made it suit our game.
Only import necessary files
2. Fix Issue that makes it go slower
Last week, we noticed an issue in the Boss Level about how after every death, the Boss Level slows down. We pinpointed the cause of this to be the HP Bar, because it kept adding more HP Bars to the canvas which caused it to lag. To solve this, we created a HPBar.js file that exported the HPBar class. This way, we could more easily destroy the HPBar when the Boss Enemy dies and unclutter the Canvas with invisible HP Bars.
3. Attack Range
We also added an attack range property to the boss so that the player can attack the boss from further away. This is so that the player can press the shift key and actually do damage to the Boss' HP, and makes the already challenging level a little bit easier.
In Boss.js