loader

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package loader provides an asset loading and caching implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetLoader

type AssetLoader struct {
	// contains filtered or unexported fields
}

AssetLoader is the struct that uses a fs.FS file system and a map for caching game assets.

func NewAssetLoader

func NewAssetLoader(dir fs.FS) *AssetLoader

NewAssetLoader takes the directory (dir fs.FS) and creates a new AssetLoader

func (*AssetLoader) GetReader

func (al *AssetLoader) GetReader(path string) (io.ReadCloser, error)

GetReader takes a path (with relation to the root directory of the asset file), returns a io.ReadCloser to interact with

path -> complete path of the asset rooted at the fs.FS

io.ReadCloser, error

func (*AssetLoader) LoadConcurrentDirectory

func (al *AssetLoader) LoadConcurrentDirectory(path, extension string, total int) []*ebiten.Image

LoadConcurrentDirectory takes a path (with relation to the root directory of the fs.FS), an asset file extension, and how many items exist in the directory

path -> goes to a directory of index named files 0.png, 1.png, 2.png extension -> the extension of the files total -> how many files exist in the directory

[]*ebiten.Image

func (*AssetLoader) LoadImage

func (al *AssetLoader) LoadImage(path string) (*ebiten.Image, error)

LoadImage takes the path, with relation to the root directory of the embeded fs.FS, and returns an *ebiten.Image, error

path -> complete path of the asset rooted at the fs.FS

*ebiten.Image, error

func (*AssetLoader) MustGetReader

func (al *AssetLoader) MustGetReader(path string) io.ReadCloser

MustGetReader takes a path (with relation to the root directory of the asset file), returns a io.ReadCloser to interact with, will panic if the file doesn't exist

path -> complete path of the asset rooted at the fs.FS

io.ReadCloser, error

func (*AssetLoader) MustLoadImage

func (al *AssetLoader) MustLoadImage(path string) *ebiten.Image

MustLoadImage takes a path (with relation to the root directory of the asset file), will panic if the file doesn't exist

path -> complete path of the asset rooted at the fs.FS

*ebiten.Image

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL