camera tweaks
This commit is contained in:
parent
a6508de705
commit
ed61e27440
1 changed files with 4 additions and 4 deletions
|
@ -12,6 +12,7 @@ type Camera struct {
|
||||||
Transform GeoMDef
|
Transform GeoMDef
|
||||||
|
|
||||||
game *Game
|
game *Game
|
||||||
|
// TODO: camera constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Camera) Draw(screen *ebiten.Image, geom ebiten.GeoM) {
|
func (c *Camera) Draw(screen *ebiten.Image, geom ebiten.GeoM) {
|
||||||
|
@ -25,6 +26,7 @@ func (c *Camera) Scan() []interface{} { return []interface{}{c.Scene} }
|
||||||
|
|
||||||
func (c *Camera) Prepare(game *Game) { c.game = game }
|
func (c *Camera) Prepare(game *Game) { c.game = game }
|
||||||
|
|
||||||
|
// Centre centres the camera on a world coordinate.
|
||||||
func (c *Camera) Centre(p image.Point) {
|
func (c *Camera) Centre(p image.Point) {
|
||||||
// Currently the centre of the screen c is A^-1.c in world coordinates
|
// Currently the centre of the screen c is A^-1.c in world coordinates
|
||||||
// So it is off by (p - A^-1.c)
|
// So it is off by (p - A^-1.c)
|
||||||
|
@ -35,7 +37,5 @@ func (c *Camera) Centre(p image.Point) {
|
||||||
t.Invert()
|
t.Invert()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Camera) Zoom(f float64) {
|
// Zoom scales the existing camera transform by f along both X and Y.
|
||||||
t := c.Transform.GeoM()
|
func (c *Camera) Zoom(f float64) { c.Transform.GeoM().Scale(f, f) }
|
||||||
t.Scale(f, f)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue