2023-07-21 19:54:39 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-07-27 12:57:11 +01:00
|
|
|
// Misc.
|
|
|
|
"log"
|
2023-07-22 23:40:06 +01:00
|
|
|
"math/rand"
|
|
|
|
|
2023-07-27 12:57:11 +01:00
|
|
|
// Ambition
|
|
|
|
p "github.com/devraza/ambition/frontend/player"
|
|
|
|
u "github.com/devraza/ambition/frontend/ui"
|
2023-07-21 19:54:39 +01:00
|
|
|
|
2023-07-22 23:40:06 +01:00
|
|
|
// Ebitengine
|
2023-07-21 19:54:39 +01:00
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
2023-08-04 14:55:53 +01:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
2023-07-21 19:54:39 +01:00
|
|
|
)
|
|
|
|
|
2023-07-23 00:34:44 +01:00
|
|
|
// Create the `Game` struct
|
2023-07-22 23:40:06 +01:00
|
|
|
type Game struct {
|
2023-07-27 12:57:11 +01:00
|
|
|
ui u.UI
|
|
|
|
activePlayer p.Player
|
2023-07-22 20:26:25 +01:00
|
|
|
}
|
|
|
|
|
2023-07-23 15:27:31 +01:00
|
|
|
// Define the window width/height
|
2023-07-23 07:57:28 +01:00
|
|
|
const (
|
2023-07-23 15:27:31 +01:00
|
|
|
window_width = 1440
|
|
|
|
window_height = 960
|
2023-07-23 07:57:28 +01:00
|
|
|
)
|
2023-07-21 19:54:39 +01:00
|
|
|
|
2023-07-23 00:34:44 +01:00
|
|
|
// Update implements Game
|
2023-07-21 19:54:39 +01:00
|
|
|
func (g *Game) Update() error {
|
2023-07-27 12:57:11 +01:00
|
|
|
g.ui.Base.Update()
|
|
|
|
g.activePlayer.Update()
|
2023-07-21 19:54:39 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-23 00:34:44 +01:00
|
|
|
// 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
|
2023-07-27 12:57:11 +01:00
|
|
|
g.ui.Base.Draw(screen)
|
2023-08-04 14:55:53 +01:00
|
|
|
ebitenutil.DebugPrint(screen, g.activePlayer.JwtToken)
|
2023-07-21 19:54:39 +01:00
|
|
|
}
|
|
|
|
|
2023-07-23 00:34:44 +01:00
|
|
|
// Layout implements Game
|
2023-07-21 19:54:39 +01:00
|
|
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
2023-07-23 00:34:44 +01:00
|
|
|
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
|
2023-07-23 07:57:28 +01:00
|
|
|
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-08-04 14:55:53 +01:00
|
|
|
game := Game{}
|
|
|
|
game.activePlayer = p.NewPlayer()
|
|
|
|
game.ui = u.UiInit(window_width, window_height, &game.activePlayer)
|
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)
|
|
|
|
}
|
|
|
|
}
|