Starting to add in assets.
This commit is contained in:
BIN
client/assets/dino_blue.png
Normal file
BIN
client/assets/dino_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_green.png
Normal file
BIN
client/assets/dino_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_red.png
Normal file
BIN
client/assets/dino_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
client/assets/dino_yellow.png
Normal file
BIN
client/assets/dino_yellow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
51
client/assets/imagebank.go
Normal file
51
client/assets/imagebank.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"image"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type ImgAssetName string
|
||||
|
||||
const (
|
||||
Green ImgAssetName = "Green"
|
||||
Blue ImgAssetName = "Blue"
|
||||
Yellow ImgAssetName = "Yellow"
|
||||
Red ImgAssetName = "Red"
|
||||
)
|
||||
|
||||
var (
|
||||
ImageBank map[ImgAssetName]*ebiten.Image
|
||||
|
||||
//go:embed dino_blue.png
|
||||
blue_img []byte
|
||||
//go:embed dino_green.png
|
||||
green_img []byte
|
||||
//go:embed dino_red.png
|
||||
red_img []byte
|
||||
//go:embed dino_yellow.png
|
||||
yellow_img []byte
|
||||
)
|
||||
|
||||
func init() {
|
||||
ImageBank = make(map[ImgAssetName]*ebiten.Image)
|
||||
|
||||
ImageBank[Blue] = LoadImageFatal(blue_img)
|
||||
ImageBank[Green] = LoadImageFatal(green_img)
|
||||
ImageBank[Red] = LoadImageFatal(red_img)
|
||||
ImageBank[Yellow] = LoadImageFatal(yellow_img)
|
||||
}
|
||||
|
||||
func LoadImageFatal(b []byte) *ebiten.Image {
|
||||
|
||||
img, _, err := image.Decode(bytes.NewReader(b))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return ebiten.NewImageFromImage(img)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user