mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 03:58:55 +01:00
examples/moire: Add comments
This commit is contained in:
parent
d6769659eb
commit
38013bbc22
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
// +build example
|
// +build example
|
||||||
|
|
||||||
|
// This example is just to check if Ebiten can draw fine checker pattern evenly.
|
||||||
|
// If there is something wrong in the implementation, the result might include
|
||||||
|
// uneven patterns (#459).
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -23,18 +26,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
initScreenWidth = 640
|
screenWidth = 640
|
||||||
initScreenHeight = 480
|
screenHeight = 480
|
||||||
initScreenScale = 1
|
initScreenScale = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gophersImage *ebiten.Image
|
|
||||||
keyStates = map[ebiten.Key]int{
|
keyStates = map[ebiten.Key]int{
|
||||||
ebiten.KeyUp: 0,
|
|
||||||
ebiten.KeyDown: 0,
|
|
||||||
ebiten.KeyLeft: 0,
|
|
||||||
ebiten.KeyRight: 0,
|
|
||||||
ebiten.KeyS: 0,
|
ebiten.KeyS: 0,
|
||||||
ebiten.KeyF: 0,
|
ebiten.KeyF: 0,
|
||||||
}
|
}
|
||||||
@ -75,26 +73,8 @@ func update(screen *ebiten.Image) error {
|
|||||||
keyStates[key]++
|
keyStates[key]++
|
||||||
}
|
}
|
||||||
screenScale := ebiten.ScreenScale()
|
screenScale := ebiten.ScreenScale()
|
||||||
d := int(32 / screenScale)
|
|
||||||
screenWidth, screenHeight := screen.Size()
|
|
||||||
fullscreen := ebiten.IsFullscreen()
|
fullscreen := ebiten.IsFullscreen()
|
||||||
|
|
||||||
if keyStates[ebiten.KeyUp] == 1 {
|
|
||||||
screenHeight += d
|
|
||||||
}
|
|
||||||
if keyStates[ebiten.KeyDown] == 1 {
|
|
||||||
if 16 < screenHeight && d < screenHeight {
|
|
||||||
screenHeight -= d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if keyStates[ebiten.KeyLeft] == 1 {
|
|
||||||
if 16 < screenWidth && d < screenWidth {
|
|
||||||
screenWidth -= d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if keyStates[ebiten.KeyRight] == 1 {
|
|
||||||
screenWidth += d
|
|
||||||
}
|
|
||||||
if keyStates[ebiten.KeyS] == 1 {
|
if keyStates[ebiten.KeyS] == 1 {
|
||||||
switch screenScale {
|
switch screenScale {
|
||||||
case 1:
|
case 1:
|
||||||
@ -110,7 +90,6 @@ func update(screen *ebiten.Image) error {
|
|||||||
if keyStates[ebiten.KeyF] == 1 {
|
if keyStates[ebiten.KeyF] == 1 {
|
||||||
fullscreen = !fullscreen
|
fullscreen = !fullscreen
|
||||||
}
|
}
|
||||||
ebiten.SetScreenSize(screenWidth, screenHeight)
|
|
||||||
ebiten.SetScreenScale(screenScale)
|
ebiten.SetScreenScale(screenScale)
|
||||||
ebiten.SetFullscreen(fullscreen)
|
ebiten.SetFullscreen(fullscreen)
|
||||||
|
|
||||||
@ -123,7 +102,7 @@ func update(screen *ebiten.Image) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := ebiten.Run(update, initScreenWidth, initScreenHeight, initScreenScale, "Moire (Ebiten Demo)"); err != nil {
|
if err := ebiten.Run(update, screenWidth, screenHeight, initScreenScale, "Moire (Ebiten Demo)"); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user