Files
fluids/elements/alert.go

50 lines
771 B
Go
Raw Normal View History

2025-11-28 18:10:37 -05:00
package elements
import (
"fluids/fonts"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/text/v2"
)
const (
AlertWidth = 50
AlertHeight = 150
)
type Alert struct {
Sprite *ebiten.Image
text string
textfacesource *text.GoTextFaceSource
}
func NewAlert() *Alert {
a := &Alert{
Sprite: ebiten.NewImage(AlertWidth, AlertHeight),
textfacesource: fonts.PixelFont,
}
return a
}
func (a *Alert) Draw() {
a.Sprite.Clear()
fnt := &text.GoTextFace{
Source: a.textfacesource,
Size: 20,
}
_, h := text.Measure(a.text, fnt, 0)
top := &text.DrawOptions{}
top.GeoM.Translate(0, h)
text.Draw(a.Sprite, a.text, fnt, top)
}
func (a *Alert) Update() {
}
func (a *Alert) SetText(t string) {
a.text = t
}