Skip to content

Instantly share code, notes, and snippets.

@doccaico
Created August 5, 2025 21:51
Show Gist options
  • Select an option

  • Save doccaico/727392df9d39d4571f9ce7318432e80a to your computer and use it in GitHub Desktop.

Select an option

Save doccaico/727392df9d39d4571f9ce7318432e80a to your computer and use it in GitHub Desktop.
Go/Golang + Ebiten/Ebitengine
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