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.2 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
// Random
"math/rand"
// Logs
2023-07-21 19:54:39 +01:00
"log"
2023-07-22 23:40:06 +01:00
// Ebitengine
2023-07-21 19:54:39 +01:00
"github.com/hajimehoshi/ebiten/v2"
)
// Create the `Game` struct
2023-07-22 23:40:06 +01:00
type Game struct {
ui UI
2023-07-22 20:26:25 +01:00
}
const (
window_width = 640
window_height = 480
)
2023-07-21 19:54:39 +01:00
// Update implements Game
2023-07-21 19:54:39 +01:00
func (g *Game) Update() error {
g.ui.base.Update()
2023-07-21 19:54:39 +01:00
return nil
}
// Draw implements Game
2023-07-21 19:54:39 +01:00
func (g *Game) Draw(screen *ebiten.Image) {
2023-07-23 00:36:55 +01:00
// Draw the UI onto the screen
g.ui.base.Draw(screen)
2023-07-21 19:54:39 +01:00
}
// Layout implements Game
2023-07-21 19:54:39 +01:00
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return outsideWidth, outsideHeight
2023-07-21 19:54:39 +01:00
}
2023-07-23 00:36:55 +01:00
// Main function
2023-07-21 19:54:39 +01:00
func main() {
2023-07-23 00:36:55 +01:00
// Randomize window titles!
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-23 00:36:55 +01:00
// Engine setup
ebiten.SetWindowSize(window_width, window_height)
2023-07-22 23:40:06 +01:00
ebiten.SetWindowTitle(window_title)
2023-07-23 00:36:55 +01:00
// Initialise the game
2023-07-22 20:26:25 +01:00
game := Game{
2023-07-23 00:36:55 +01:00
// Initialise the UI
ui: uiInit(window_width, window_height),
2023-07-22 20:26:25 +01:00
}
2023-07-23 00:36:55 +01:00
// Log and exit on error
2023-07-22 20:26:25 +01:00
if err := ebiten.RunGame(&game); err != nil {
2023-07-21 19:54:39 +01:00
log.Fatal(err)
}
}