Skip to content

Commit

Permalink
Update game blance
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki0418 committed Nov 12, 2020
1 parent a0919db commit 510cf73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 15 additions & 5 deletions base-shooter/Bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,26 @@ class Bubble {
velocityY;
speed;
health; // Hit point
maxHealth;
isHitted;
isKilled;

colors = [
'#EA6B54',
'#EBB160',
'#F3D788',
'#97A87D',
'#B3ACA0',
]

constructor(x, y, ctx) {
this.x = x;
this.y = y;
this.speed = (Math.random() * 0.003) + 0.001;
this.speed = 0.0007;
this.ctx = ctx;
this.isHitted = false;
this.isKilled = false;
this.maxHealth = 5;
this.setVelocities();
this.setHealth();
this.setRadius();
Expand All @@ -25,16 +35,16 @@ class Bubble {
show() {
this.ctx.save();
this.ctx.beginPath();
this.ctx.fillStyle = 'white';
this.ctx.fillStyle = this.colors[this.health - 1] || 'white';
this.ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2);
this.ctx.fill();
this.ctx.closePath();
this.ctx.restore();
}

update() {
this.x += this.velocityX * this.speed;
this.y += this.velocityY * this.speed;
this.x += this.velocityX * (this.maxHealth - this.health) * this.speed;
this.y += this.velocityY * (this.maxHealth - this.health) * this.speed;
}

setVelocities() {
Expand All @@ -43,7 +53,7 @@ class Bubble {
}

setHealth() {
const randomHelth = Math.floor(Math.random() * 5);
const randomHelth = Math.floor(Math.random() * this.maxHealth) + 1;
this.health = randomHelth;
}

Expand Down
6 changes: 0 additions & 6 deletions base-shooter/Bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ class Bullet {
this.x += this.velocityX * this.speed;
this.y += this.velocityY * this.speed;
}

// setDeg() {
// let targetX = (this.clickedPosi.x - this.canvas.width / 2) - this.x;
// let targetY = (this.clickedPosi.y - this.canvas.height / 2) - this.y;
// this.deg = Math.atan2(targetY, targetX) - Math.PI / 4;
// }

setVelocities() {
let dx = this.clickedPosi.x - this.x;
Expand Down

0 comments on commit 510cf73

Please sign in to comment.