diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-07 09:39:29 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-07 09:39:29 +0200 |
| commit | 2b05b9d8aa47f6cc9d768c6758f1cca4e8721a4c (patch) | |
| tree | 17b59634ce20f42111e30cd199a77960a386008a /draw.go | |
| parent | b3e70bf4cf7e790fa8b5239c05b6c7b917f19635 (diff) | |
Regroup drawing
Diffstat (limited to 'draw.go')
| -rw-r--r-- | draw.go | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "image/color" + + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/text/v2" +) + +func (e *Entity) Draw(g *Game, screen *ebiten.Image) { + if !e.Image.IsEnabled || !e.Position.IsEnabled { + return + } + op := &ebiten.DrawImageOptions{} + op.GeoM.Translate(float64(e.Position.Value.X), float64(e.Position.Value.Y)) + screen.DrawImage(e.Image.Value, op) + if e.Selection.IsEnabled && e.Selection.Value.IsSelected { + opt := &ebiten.DrawImageOptions{} + opt.GeoM.Translate(float64(e.Position.Value.X-SELECTION_HALO_WIDTH/2), float64(e.Position.Value.Y-SELECTION_HALO_WIDTH/2)) + screen.DrawImage(e.Selection.Value.Halo, opt) + if e.ResourceSource.IsEnabled { + resourceText := fmt.Sprintf("%d", e.ResourceSource.Value.Remaining) + op := &text.DrawOptions{} + op.GeoM.Translate(float64(e.Position.Value.X+5), float64(e.Position.Value.Y+30)) + op.ColorScale.ScaleWithColor(color.White) + text.Draw(screen, resourceText, &text.GoTextFace{ + Source: g.FaceSource, + Size: 40, + }, op) + } + } +} |
