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"
|
2023-07-23 15:27:31 +01:00
|
|
|
// "github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
2023-07-21 19:54:39 +01:00
|
|
|
)
|
|
|
|
|
2023-07-23 21:37:24 +01:00
|
|
|
// Initialise the test player
|
|
|
|
var testPlayer = initPlayer()
|
|
|
|
|
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-23 15:27:31 +01:00
|
|
|
ui UI
|
2023-07-23 09:20:48 +01:00
|
|
|
activePlayer 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-23 07:57:28 +01:00
|
|
|
g.ui.base.Update()
|
2023-07-23 09:20:48 +01:00
|
|
|
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-23 07:57:28 +01:00
|
|
|
g.ui.base.Draw(screen)
|
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 15:27:31 +01:00
|
|
|
|
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
|
2023-07-23 09:20:48 +01:00
|
|
|
activePlayer: testPlayer,
|
2023-07-23 21:37:24 +01:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|