mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
Simplify rotate/main.go
This commit is contained in:
parent
a653ba9258
commit
161b3d1316
@ -28,32 +28,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
count int
|
||||
horizontalCount int
|
||||
verticalCount int
|
||||
gophersImage *ebiten.Image
|
||||
count int
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
if ebiten.IsKeyPressed(ebiten.KeyLeft) {
|
||||
horizontalCount--
|
||||
}
|
||||
if ebiten.IsKeyPressed(ebiten.KeyRight) {
|
||||
horizontalCount++
|
||||
}
|
||||
if ebiten.IsKeyPressed(ebiten.KeyDown) {
|
||||
verticalCount--
|
||||
}
|
||||
if ebiten.IsKeyPressed(ebiten.KeyUp) {
|
||||
verticalCount++
|
||||
}
|
||||
|
||||
w, h := gophersImage.Size()
|
||||
geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2)
|
||||
scaleX := math.Pow(1.05, float64(horizontalCount))
|
||||
scaleY := math.Pow(1.05, float64(verticalCount))
|
||||
geo.Concat(ebiten.ScaleGeo(scaleX, scaleY))
|
||||
geo.Concat(ebiten.RotateGeo(float64(count%720) * 2 * math.Pi / 720))
|
||||
geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2))
|
||||
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
||||
|
Loading…
Reference in New Issue
Block a user