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

68 lines
1.3 KiB
Go
Raw Normal View History

2023-07-21 19:54:39 +01:00
package main
import (
2023-07-22 23:40:06 +01:00
// Image-related packages
img "image"
"image/color"
// Random
"math/rand"
// Logs
2023-07-21 19:54:39 +01:00
"log"
2023-07-22 23:40:06 +01:00
// Ebitengine
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 23:40:06 +01:00
type Game struct {
2023-07-22 20:26:25 +01:00
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)
2023-07-22 23:40:06 +01:00
2023-07-22 20:26:25 +01:00
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() {
2023-07-22 23:40:06 +01:00
window_titles := []string{
"coding into the online cyberframe",
"seriously prideful",
"[REDACTED]",
"just another day of shooting down bevies",
"mud is delicious",
}
window_title := "Ambition: " + window_titles[rand.Intn(len(window_titles))]
2023-07-21 19:54:39 +01:00
ebiten.SetWindowSize(640, 480)
2023-07-22 23:40:06 +01:00
ebiten.SetWindowTitle(window_title)
2023-07-22 20:26:25 +01:00
game := Game{
ui: uiInit(),
}
if err := ebiten.RunGame(&game); err != nil {
2023-07-21 19:54:39 +01:00
log.Fatal(err)
}
}