Created
August 5, 2025 21:51
-
-
Save doccaico/727392df9d39d4571f9ce7318432e80a to your computer and use it in GitHub Desktop.
Go/Golang + Ebiten/Ebitengine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "image/color" | |
| "log" | |
| "github.com/hajimehoshi/ebiten/v2" | |
| "github.com/hajimehoshi/ebiten/v2/ebitenutil" | |
| ) | |
| const ( | |
| ScreenWidth = 480 | |
| ScreenHeight = 640 | |
| ) | |
| var ( | |
| backgroundColor = color.RGBA{0xff, 0xff, 0xff, 0xff} | |
| ) | |
| type Game struct{} | |
| func (g *Game) Update() error { | |
| return nil | |
| } | |
| func (g *Game) Draw(screen *ebiten.Image) { | |
| screen.Fill(backgroundColor) | |
| ebitenutil.DrawRect(screen, 0.0, 0.0, 32.0, 32.0, color.RGBA{0xff, 0, 0, 0xff}) | |
| } | |
| func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { | |
| return outsideWidth, outsideHeight | |
| } | |
| func main() { | |
| ebiten.SetWindowSize(ScreenWidth, ScreenHeight) | |
| ebiten.SetWindowTitle("Hello, World!") | |
| if err := ebiten.RunGame(&Game{}); err != nil { | |
| log.Fatal(err) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment