mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
Simplify rotate/main.go
This commit is contained in:
parent
a653ba9258
commit
161b3d1316
@ -29,31 +29,13 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
count int
|
count int
|
||||||
horizontalCount int
|
|
||||||
verticalCount int
|
|
||||||
gophersImage *ebiten.Image
|
gophersImage *ebiten.Image
|
||||||
)
|
)
|
||||||
|
|
||||||
func update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
count++
|
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()
|
w, h := gophersImage.Size()
|
||||||
geo := ebiten.TranslateGeo(-float64(w)/2, -float64(h)/2)
|
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.RotateGeo(float64(count%720) * 2 * math.Pi / 720))
|
||||||
geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2))
|
geo.Concat(ebiten.TranslateGeo(screenWidth/2, screenHeight/2))
|
||||||
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
if err := screen.DrawImage(gophersImage, &ebiten.DrawImageOptions{
|
||||||
|
Loading…
Reference in New Issue
Block a user