package assets

import (
	"bytes"
	_ "embed"
	"image"
	_ "image/png"
	"log"

	"github.com/hajimehoshi/ebiten/v2"
)

type ImgAssetName string

const (
	Ducky   ImgAssetName = "Ducky"
	ReDucky ImgAssetName = "ReDucky"
	Orb     ImgAssetName = "Orb"
)

var (
	ImageBank map[ImgAssetName]*ebiten.Image

	//go:embed duck_idle.png
	duckidle_img []byte
	//go:embed reducky_idle.png
	reduckidle_img []byte
	//go:embed orb.png
	orb_img []byte
)

func LoadImages() {
	ImageBank = make(map[ImgAssetName]*ebiten.Image)
	ImageBank[Ducky] = LoadImagesFatal(duckidle_img)
	ImageBank[ReDucky] = LoadImagesFatal(reduckidle_img)
	ImageBank[Orb] = LoadImagesFatal(orb_img)
}

func LoadImagesFatal(b []byte) *ebiten.Image {
	img, _, err := image.Decode(bytes.NewReader(b))
	if err != nil {
		log.Fatal(err)
	}
	return ebiten.NewImageFromImage(img)
}
