diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-06-06 20:59:12 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-06-06 20:59:12 +0200 |
| commit | d9a54f1319cc9dcc2861cecc9edfde14cf039c5b (patch) | |
| tree | 74df791d6eda0ffe6c09cb32e5ffd76c4849cbac /engine/image.go | |
| parent | 18592fd9f520a33ab307e496b995c1a7bf284893 (diff) | |
Add examples catalog with subcommand dispatch
- Extract game engine from package main to engine/ library package
- Create examples/ package with registry, Entry type, and BuilderDeps
- Register default world as an example (moved from main())
- Add combat example: two teams of units facing each other
- Rewrite main.go as thin dispatch: go run . example [name]
- Update README with examples catalog one-liner
Diffstat (limited to 'engine/image.go')
| -rw-r--r-- | engine/image.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/engine/image.go b/engine/image.go new file mode 100644 index 0000000..07cac55 --- /dev/null +++ b/engine/image.go @@ -0,0 +1,33 @@ +package engine + +import ( + "age_of_empires/physics" + "image/color" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/vector" +) + +func NewFilledRectangleImage(size physics.Point, color color.Color) *ebiten.Image { + image := ebiten.NewImage(size.X, size.Y) + image.Fill(color) + return image +} + +func NewStrokeRectangleImage(size physics.Point, strokeWidth float32, color color.Color) *ebiten.Image { + image := ebiten.NewImage(size.X, size.Y) + vector.StrokeRect(image, 0, 0, float32(size.X), float32(size.Y), float32(strokeWidth), color, true) + return image +} + +func NewFilledCircleImage(width int, color color.Color) *ebiten.Image { + image := ebiten.NewImage((width), (width)) + vector.DrawFilledCircle(image, float32(width/2), float32(width/2), float32(width/2), color, true) + return image +} + +func NewStrokeCircleImage(width int, strokeWidth int, color color.Color) *ebiten.Image { + image := ebiten.NewImage((width), (width)) + vector.StrokeCircle(image, float32(width/2), float32(width/2), float32(width/2), float32(strokeWidth), color, true) + return image +} |
