Fix turret rotation center

This commit is contained in:
Trevor Slocum 2024-02-08 21:47:11 -08:00
parent 5e162fcf20
commit 547089d478

View file

@ -597,9 +597,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
op.GeoM.Translate(float64(x), float64(y))
screen.DrawImage(tankHullImages[1], op)
op = &ebiten.DrawImageOptions{}
op.GeoM.Translate(-51, -51)
op.GeoM.Translate(-50, -50)
op.GeoM.Rotate(math.Pi/2 + g.title1)
op.GeoM.Translate(51, 51)
op.GeoM.Translate(50, 50)
op.GeoM.Translate(float64(x), float64(y))
screen.DrawImage(tankTurretImages[1], op)
@ -611,9 +611,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
op.GeoM.Translate(float64(x), float64(y))
screen.DrawImage(tankHullImages[2], op)
op = &ebiten.DrawImageOptions{}
op.GeoM.Translate(-51, -51)
op.GeoM.Translate(-50, -50)
op.GeoM.Rotate(math.Pi/2 + math.Pi + g.title2)
op.GeoM.Translate(51, 51)
op.GeoM.Translate(50, 50)
op.GeoM.Translate(float64(x), float64(y))
screen.DrawImage(tankTurretImages[2], op)
@ -830,9 +830,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
offset(op)
screen.DrawImage(tankHullImages[state.S], op)
op = &ebiten.DrawImageOptions{}
op.GeoM.Translate(-51, -51)
op.GeoM.Translate(-50, -50)
op.GeoM.Rotate(math.Pi/2 + state.R + state.T)
op.GeoM.Translate(51, 51)
op.GeoM.Translate(50, 50)
op.GeoM.Translate(float64(state.X), float64(state.Y))
offset(op)
if state.Hit {