diff --git a/src/js/canvas.js b/src/js/canvas.js index 2b3eb0d1f651ed825bceef381dcf6e7f5ae768ec..71db88823a3b37df36cab731f0e62c7cc38bf293 100644 --- a/src/js/canvas.js +++ b/src/js/canvas.js @@ -63,6 +63,11 @@ class Canvas { this.ctx.fillStyle = c; this.ctx.fillRect(x-this.cX, y-this.cY, w, h); } + + strokeRect(x, y, w, h, c="white") { + this.ctx.strokeStyle = c; + this.ctx.strokeRect(x-this.cX, y-this.cY, w, h); + } } diff --git a/src/js/game.js b/src/js/game.js index e289fe2c5779c7ccb738ff5195dcec754429a8fa..5094891e8613be47ddc2b7074b4257ea8eb7a526 100644 --- a/src/js/game.js +++ b/src/js/game.js @@ -195,7 +195,7 @@ class Boat extends Entity { this.sprite = sprite; this.speed = speed; if (speed === 0) speed = 0.5; - this.stepspeed = randomInt(Math.floor(100/speed), Math.floor(1000/speed)); + this.stepspeed = randomInt(Math.floor(500/speed), Math.floor(1500/speed)); this.target = target; } @@ -248,7 +248,9 @@ gameRoom.wavePendingStart = 0; gameRoom.boatCount = 0; gameRoom.boatSpeed = 0; -gameRoom.boatAvoid = {} +gameRoom.boatAvoid = [ + {x: 35, y: 100, w: 32, h: 75} +]; console.log(typeof(gameRoom.remove)) @@ -277,6 +279,10 @@ gameRoom.draw = () => { for (const item of gameRoom.objects) { item.draw(); } + + for (const hitbox of gameRoom.boatAvoid) { + canvas.strokeRect(hitbox.x, hitbox.y, hitbox.w, hitbox.h, "red"); + } } gameRoom.step = _ => { let numberOfBoats = 0;