simplification

This commit is contained in:
Zutatensuppe 2020-11-10 18:48:16 +01:00
parent 1605fdfc99
commit 905946da06
8 changed files with 138 additions and 608 deletions

View file

@ -1,5 +1,3 @@
import BoundingRectangle from "./BoundingRectangle.js"
export default class Camera {
constructor(canvas) {
this.x = 0
@ -17,12 +15,12 @@ export default class Camera {
}
rect() {
return new BoundingRectangle(
- this.x,
- this.x + (this.width / this.zoom),
- this.y,
- this.y + (this.height / this.zoom),
)
return {
x: -this.x,
y: -this.y,
w: this.width / this.zoom,
h: this.height / this.zoom,
}
}
move(x, y) {
@ -79,4 +77,11 @@ export default class Camera {
y: (coord.y + this.y) * this.zoom,
}
}
worldDimToViewport(dim) {
return {
w: dim.w * this.zoom,
h: dim.h * this.zoom,
}
}
}