laser bullet
This commit is contained in:
parent
75262316b5
commit
807dbe828b
34
Script.js
34
Script.js
@ -119,9 +119,8 @@ function keyDownPressed(e) {
|
||||
|
||||
if (e.keyCode == 32) {
|
||||
keys.fire = true;
|
||||
missilesArray.push(
|
||||
new Missile(player1.x + 120, player1.y + 50, "white", 12)
|
||||
);
|
||||
missilesArray.push(new LaserBullet(player1.x + 150, player1.y + 50));
|
||||
|
||||
|
||||
laser.currentTime = 0;
|
||||
laser.play();
|
||||
@ -287,22 +286,30 @@ function addStarField() {
|
||||
background1a.update();
|
||||
}
|
||||
|
||||
class Missile {
|
||||
constructor(x, y, color, speed) {
|
||||
class LaserBullet {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 3;
|
||||
this.height = 10;
|
||||
this.color = color;
|
||||
this.speed = speed;
|
||||
this.width = 14;
|
||||
this.height = 4;
|
||||
this.speed = 16;
|
||||
}
|
||||
|
||||
draw() {
|
||||
ctx.save();
|
||||
ctx.fillStyle = this.color;
|
||||
let g = ctx.createLinearGradient(
|
||||
this.x,
|
||||
this.y,
|
||||
this.x + this.width,
|
||||
this.y
|
||||
);
|
||||
g.addColorStop(0, "#00e1ff");
|
||||
g.addColorStop(0.5, "#ffffff");
|
||||
g.addColorStop(1, "#00e1ff");
|
||||
ctx.fillStyle = g;
|
||||
ctx.shadowColor = "#00ffff";
|
||||
ctx.shadowBlur = 15;
|
||||
ctx.fillRect(this.x, this.y, this.width, this.height);
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
ctx.shadowBlur = 0;
|
||||
}
|
||||
|
||||
update() {
|
||||
@ -310,6 +317,7 @@ class Missile {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class EnemyObj {
|
||||
constructor(x, y, speed) {
|
||||
this.x = x;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user