package main

import (
	"log"

	"github.com/hajimehoshi/ebiten/v2"

	"src.robn.tv/MrDonuts/RGB/assets"
	geom "src.robn.tv/MrDonuts/RGB/geometry"
	"src.robn.tv/MrDonuts/RGB/states"
	score "src.robn.tv/MrDonuts/RGB/tools"
)

func init() {

	numRows := 3
	numColumns := 6
	geom.BuildGrid(numRows, numColumns)

	states.SetupStateMachine()

	//some audio testing
	for i, song := range assets.SongTracks {
		song.Play()
		if i != 1 {
			song.SetVolume(0)
		} else {
			song.SetVolume(0.7)
		}
	}

}

type Game struct{}

func (g *Game) Update() error {

	states.SM.Update()
	score.ScoreMngr.Update()

	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {

	states.SM.Draw(screen)

}

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
	return 640, 480
}

func main() {
	ebiten.SetWindowSize(640, 480)
	ebiten.SetWindowTitle("RGB")
	if err := ebiten.RunGame(&Game{}); err != nil {
		log.Fatal(err)
	}
}
