2020-06-21 18:40:37 -04:00
|
|
|
package d2maprenderer
|
2019-12-08 22:18:42 -05:00
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Camera is the position of the camera perspective in orthogonal world space. See viewport.go.
|
|
|
|
// TODO: Has a coordinate (issue #456)
|
2019-12-08 22:18:42 -05:00
|
|
|
type Camera struct {
|
|
|
|
x float64
|
|
|
|
y float64
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// MoveTo sets the position of the camera to the given x and y coordinates.
|
2019-12-08 22:18:42 -05:00
|
|
|
func (c *Camera) MoveTo(x, y float64) {
|
|
|
|
c.x = x
|
|
|
|
c.y = y
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// MoveBy adds the given vector to the current position of the camera.
|
2019-12-08 22:18:42 -05:00
|
|
|
func (c *Camera) MoveBy(x, y float64) {
|
|
|
|
c.x += x
|
|
|
|
c.y += y
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// GetPosition returns the camera x and y position.
|
2019-12-08 22:18:42 -05:00
|
|
|
func (c *Camera) GetPosition() (float64, float64) {
|
|
|
|
return c.x, c.y
|
|
|
|
}
|