examples/windowscale: Use float scale factor

This commit is contained in:
Hajime Hoshi 2016-06-25 02:17:08 +09:00
parent 71ded00886
commit bf807799bf

View File

@ -49,14 +49,9 @@ func update(screen *ebiten.Image) error {
} }
keyStates[key]++ keyStates[key]++
} }
d := 0
screenScale := ebiten.ScreenScale() screenScale := ebiten.ScreenScale()
switch screenScale { d := int(32 / screenScale)
case 1:
d = 32
case 2:
d = 16
}
screenWidth, screenHeight := screen.Size() screenWidth, screenHeight := screen.Size()
if keyStates[ebiten.KeyUp] == 1 { if keyStates[ebiten.KeyUp] == 1 {
screenHeight += d screenHeight += d
@ -75,7 +70,16 @@ func update(screen *ebiten.Image) error {
screenWidth += d screenWidth += d
} }
if keyStates[ebiten.KeyS] == 1 { if keyStates[ebiten.KeyS] == 1 {
screenScale = 3 - screenScale // Swap 1 and 2 switch screenScale {
case 1:
screenScale = 1.5
case 1.5:
screenScale = 2
case 2:
screenScale = 1
default:
panic("not reach")
}
} }
ebiten.SetScreenSize(screenWidth, screenHeight) ebiten.SetScreenSize(screenWidth, screenHeight)
ebiten.SetScreenScale(screenScale) ebiten.SetScreenScale(screenScale)