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
2023-07-23 21:37:24 +01:00

76 lines
1.4 KiB
Go

package main
import (
// Random
"math/rand"
// Logs
"log"
// Ebitengine
"github.com/hajimehoshi/ebiten/v2"
// "github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
// Initialise the test player
var testPlayer = initPlayer()
// Create the `Game` struct
type Game struct {
ui UI
activePlayer Player
}
// Define the window width/height
const (
window_width = 1440
window_height = 960
)
// Update implements Game
func (g *Game) Update() error {
g.ui.base.Update()
g.activePlayer.update()
return nil
}
// Draw implements Game
func (g *Game) Draw(screen *ebiten.Image) {
// Draw the UI onto the screen
g.ui.base.Draw(screen)
}
// Layout implements Game
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return outsideWidth, outsideHeight
}
// Main function
func main() {
// Randomize window titles!
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))]
// Engine setup
ebiten.SetWindowSize(window_width, window_height)
ebiten.SetWindowTitle(window_title)
// Initialise the game
game := Game{
// Initialise the UI
activePlayer: testPlayer,
ui: uiInit(window_width, window_height),
}
// Log and exit on error
if err := ebiten.RunGame(&game); err != nil {
log.Fatal(err)
}
}