add rotation
This commit is contained in:
parent
f3bff2b393
commit
30224c15bf
2 changed files with 6 additions and 4 deletions
|
@ -26,6 +26,7 @@ type Camera struct {
|
||||||
// Camera controls
|
// Camera controls
|
||||||
Centre image.Point // world coordinates
|
Centre image.Point // world coordinates
|
||||||
Filter ebiten.Filter
|
Filter ebiten.Filter
|
||||||
|
Rotation float64 // radians
|
||||||
Zoom float64 // unitless
|
Zoom float64 // unitless
|
||||||
|
|
||||||
game *Game
|
game *Game
|
||||||
|
|
|
@ -79,8 +79,9 @@ func (s *Scene) Draw(screen *ebiten.Image, opts ebiten.DrawImageOptions) {
|
||||||
// Compute common matrix (parts independent of parallax, which is step 1).
|
// Compute common matrix (parts independent of parallax, which is step 1).
|
||||||
// Moving centre to the origin happens per component.
|
// Moving centre to the origin happens per component.
|
||||||
var comm ebiten.GeoM
|
var comm ebiten.GeoM
|
||||||
// 2. Zoom (this is also where rotation would be)
|
// 2. Zoom and rotate
|
||||||
comm.Scale(zoom, zoom)
|
comm.Scale(zoom, zoom)
|
||||||
|
comm.Rotate(s.Camera.Rotation)
|
||||||
// 3. Move the origin to the centre of screen space.
|
// 3. Move the origin to the centre of screen space.
|
||||||
comm.Translate(sw2, sh2)
|
comm.Translate(sw2, sh2)
|
||||||
// 4. Apply transforms from the caller.
|
// 4. Apply transforms from the caller.
|
||||||
|
|
Loading…
Reference in a new issue