simplification
This commit is contained in:
parent
1605fdfc99
commit
905946da06
8 changed files with 138 additions and 608 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue