Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
/bin/
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Math-Attack</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
22 changes: 18 additions & 4 deletions src/boss.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Boss{
};//x and y position
this.height = 50;
this.width = 50;
this.velocity = {
this.velocity = {
x:0,
y:0,
}
Expand All @@ -47,14 +47,19 @@ export default class Boss{
let healthBarWidthPct = 15;
let healthBarHeightPct = 5;
this.healthBar = new HealthBar(2, 2, healthBarWidthPct, healthBarHeightPct, this.gameWidth,this.gameHeight);

/* setInterval (this.updateHealthBar, 10);*///continuously ensures that health bar on screen is accurate to real health percentage
var self = this;
this.intervalID = setInterval(
function() { self.projectileAttack()},
5000);
}



resetBoss(){
this.health = this.healthMax; // Health is a certain amount of HP
this.healthPct = 100; // Integer out of 100
this.updateHealthBar();
this.updateHealthBar();
this.weapon = weapon; //health as an integer percentage out of 100
this.position = {
x:930,
Expand All @@ -68,6 +73,7 @@ export default class Boss{
this.bossBullets = [];
}


updateHealthBar()//updates the health bar displayed on screen
{
this.healthBar.setHealthPercent(this.healthPct);
Expand All @@ -90,14 +96,22 @@ export default class Boss{
}

projectileAttack(){
console.log("Is running");
//console.log('boss attack');
if(this.healthPct >0) {
this.Xdiff=this.position.x-this.player.position.x;
this.Ydiff=this.position.y-this.player.position.y;

this.bossBullets.push(new BossBullet(this.position.x,this.position.y, this.Xdiff, this.Ydiff, this.gameWidth, this.gameHeight, this.player));
console.log("is shooting");
}
}
else {
console.log("is not shooting");
clearInterval(bossInterval);
}
}



draw(ctx){
this.healthBar.draw(ctx);
Expand Down