examples/flappy: Bug fix: wrong calculation of rotating

This commit is contained in:
Hajime Hoshi 2018-04-08 00:38:52 +09:00
parent f2e2f602c5
commit ce2168c0d6

View File

@ -371,10 +371,10 @@ func (g *Game) drawTiles(screen *ebiten.Image) {
func (g *Game) drawGopher(screen *ebiten.Image) {
op := &ebiten.DrawImageOptions{}
_, h := gopherImage.Size()
op.GeoM.Translate(-float64(h)/2.0, -float64(h)/2.0)
w, h := gopherImage.Size()
op.GeoM.Translate(-float64(w)/2.0, -float64(h)/2.0)
op.GeoM.Rotate(float64(g.vy16) / 96.0 * math.Pi / 6)
op.GeoM.Translate(float64(h)/2.0, float64(h)/2.0)
op.GeoM.Translate(float64(w)/2.0, float64(h)/2.0)
op.GeoM.Translate(float64(g.x16/16.0)-float64(g.cameraX), float64(g.y16/16.0)-float64(g.cameraY))
op.Filter = ebiten.FilterLinear
screen.DrawImage(gopherImage, op)