diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-01-24 00:27:50 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:44 +0100 |
| commit | 73d40903aecad3efcf7c6055c133f0db86558203 (patch) | |
| tree | e9c8f00fb186e270da92f273f570579f2d0b0d95 /go/ui/stateBar.go | |
| parent | fbba48698d8f8b83dfd7d914b0e37338e0d4e2ef (diff) | |
| download | muhqs-game-73d40903aecad3efcf7c6055c133f0db86558203.tar.gz muhqs-game-73d40903aecad3efcf7c6055c133f0db86558203.zip | |
intermediate commit
Diffstat (limited to 'go/ui/stateBar.go')
| -rw-r--r-- | go/ui/stateBar.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/go/ui/stateBar.go b/go/ui/stateBar.go new file mode 100644 index 00000000..e175c0c5 --- /dev/null +++ b/go/ui/stateBar.go @@ -0,0 +1,42 @@ +package ui + +import ( + "fmt" + + "github.com/hajimehoshi/ebiten/v2" + "muhq.space/muhqs-game/go/game" +) + +type StateBar struct { + X, Y int + Width, Height int + gameState *game.State + activePlayer *game.Player + ressourceView *TextBox +} + +func NewStateBar(x, y int, width, height int, s *game.State, p *game.Player) *StateBar { + sb := &StateBar{x, y, width, height, s, p, nil} + return sb +} + +func (sb *StateBar) ressourceLabel() string { + return fmt.Sprintf("%d", sb.activePlayer.Ressource) +} + +func (sb *StateBar) Draw(screen *ebiten.Image) { + if sb.ressourceView == nil { + sb.ressourceView = NewFixedTextBox(sb.X, sb.Y+sb.Height-sb.Width, sb.Width, sb.Width, + sb.ressourceLabel()) + } + sb.ressourceView.Draw(screen) +} + +func (sb *StateBar) FindObjectAt(x, y int) interface{} { + return nil +} + +func (sb *StateBar) ForceRedraw() { + sb.ressourceView.Text = sb.ressourceLabel() + sb.ressourceView = nil +} |
