package main

import (
	"github.com/soer/football/internal/game"
	"github.com/soer/football/internal/render"
	"github.com/hajimehoshi/ebiten/v2"
	"log"
)

type Game struct {
	matchManager *game.MatchManager
	renderer     *render.Renderer
}

func (g *Game) Update() error {
	g.matchManager.Update()
	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
	g.renderer.DrawWorld(screen, g.matchManager.World)
	g.renderer.DrawUI(screen, g.matchManager)
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
	return 1280, 720
}

func main() {
	ebiten.SetWindowSize(1280, 720)
	ebiten.SetWindowTitle("AI Hockey Simulation")

	matchManager := game.NewMatchManager(game.NewWorld(), 60*60, 60*3)
	g := &Game{
		matchManager: matchManager,
		renderer:     render.NewRenderer(),
	}

	// Give the puck some initial velocity to see it move
	g.matchManager.World.Puck.Velocity.X = 2
	g.matchManager.World.Puck.Velocity.Y = 1.5

	if err := ebiten.RunGame(g); err != nil {
		log.Fatal(err)
	}
}
