mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
examples/windowscale: Use float scale factor
This commit is contained in:
parent
71ded00886
commit
bf807799bf
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user