diff --git a/game/Camera.js b/game/Camera.js index 9338986..c9e2cb4 100644 --- a/game/Camera.js +++ b/game/Camera.js @@ -1,28 +1,14 @@ export default class Camera { - constructor(canvas) { + constructor() { this.x = 0 this.y = 0 - // TODO: when canvas resizes, this should - // syncronize with the cam - this.width = canvas.width - this.height = canvas.height - this.zoom = 1 this.minZoom = .1 this.maxZoom = 6 this.zoomStep = .05 } - rect() { - return { - x: -this.x, - y: -this.y, - w: this.width / this.zoom, - h: this.height / this.zoom, - } - } - move(x, y) { this.x += x / this.zoom this.y += y / this.zoom @@ -34,10 +20,7 @@ export default class Camera { return false } - const zoomToCoord = viewportCoordCenter || { - x: this.width / 2, - y: this.height / 2 - } + const zoomToCoord = viewportCoordCenter const zoomFactor = (1 / this.zoom) - (1 / zoom) this.x -= Math.round(zoomToCoord.x * zoomFactor) diff --git a/game/game.js b/game/game.js index fe4ad60..306b100 100644 --- a/game/game.js +++ b/game/game.js @@ -408,7 +408,7 @@ async function main() { // initialize some view data // this global data will change according to input events - const viewport = new Camera(canvas) + const viewport = new Camera() // center viewport viewport.move( -(TABLE_WIDTH - viewport.width) /2,