This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
ambition-legacy/frontend/main.go

52 lines
1 KiB
Go
Raw Normal View History

2023-07-21 19:54:39 +01:00
package main
import (
"log"
2023-07-22 20:26:25 +01:00
"github.com/ebitenui/ebitenui"
"github.com/ebitenui/ebitenui/image"
"github.com/ebitenui/ebitenui/widget"
2023-07-21 19:54:39 +01:00
"github.com/hajimehoshi/ebiten/v2"
2023-07-22 20:26:25 +01:00
img "image"
"image/color"
2023-07-21 19:54:39 +01:00
)
2023-07-22 20:26:25 +01:00
type Game struct{
ui ebitenui.UI
}
func uiInit() ebitenui.UI {
ui := ebitenui.UI{
Container: widget.NewContainer(widget.ContainerOpts.Layout(widget.NewAnchorLayout())),
}
leftBar := widget.NewContainer(widget.ContainerOpts.BackgroundImage(image.NewNineSliceColor(color.White)))
leftBar.SetLocation(img.Rect(0, 0, 1, 1))
ui.Container.AddChild(leftBar)
return ui
}
2023-07-21 19:54:39 +01:00
func (g *Game) Update() error {
2023-07-22 20:26:25 +01:00
g.ui.Update()
2023-07-21 19:54:39 +01:00
return nil
}
func (g *Game) Draw(screen *ebiten.Image) {
2023-07-22 20:26:25 +01:00
g.ui.Draw(screen)
2023-07-21 19:54:39 +01:00
}
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return 320, 240
}
func main() {
ebiten.SetWindowSize(640, 480)
2023-07-22 20:26:25 +01:00
ebiten.SetWindowTitle("ambition: seriously prideful")
game := Game{
ui: uiInit(),
}
if err := ebiten.RunGame(&game); err != nil {
2023-07-21 19:54:39 +01:00
log.Fatal(err)
}
}