Documentation
¶
Index ¶
- Constants
- Variables
- func Exit()
- func GetAsset[T any](file AssetFile) (T, error)
- func GetImage(file AssetFile) (*ebiten.Image, error)
- func HasAssetTypeSupport(t AssetType) bool
- func LoadAssets(files ...AssetFile) error
- func MustGetAsset[T any](file AssetFile) T
- func MustGetImage(file AssetFile) *ebiten.Image
- func MustLoadAssets(files ...AssetFile)
- func MustUnloadAssets(files ...AssetFile)
- func RegisterAssetFilesystem(root AssetRoot, filesystem fs.FS) error
- func RegisterAssetImporter(manager *AssetImporter) error
- func RegisterImageAssetImport()
- func Run(a *App) error
- func UnloadAssets(files ...AssetFile) error
- type App
- func (a *App) Context() Context
- func (a *App) Draw(screen *ebiten.Image)
- func (a *App) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
- func (a *App) Update() error
- func (a *App) WithDraw(drawFunc DrawFunc) *App
- func (a *App) WithFixedUpdate(fixedUpdateFunc UpdateFunc) *App
- func (a *App) WithLateUpdate(lateUpdateFunc UpdateFunc) *App
- func (a *App) WithLayout(layoutFunc LayoutFunc) *App
- func (a *App) WithLogger(logger *slog.Logger) *App
- func (a *App) WithShutdown(shutdownFunc ShutdownFunc) *App
- func (a *App) WithStartup(startupFunc StartupFunc) *App
- func (a *App) WithUpdate(updateFunc UpdateFunc) *App
- func (a *App) WithWindow(window *Window) *App
- type AssetAllocator
- type AssetDeallocator
- type AssetFile
- func (f AssetFile) Get() (any, error)
- func (f AssetFile) Load() error
- func (f AssetFile) MustGet() any
- func (f AssetFile) MustLoad()
- func (f AssetFile) MustUnload()
- func (f AssetFile) Path() string
- func (f AssetFile) Root() AssetRoot
- func (f AssetFile) Type() AssetType
- func (f AssetFile) Unload() error
- type AssetImporter
- type AssetRoot
- type AssetType
- type Context
- type ContextKey
- type DrawFunc
- type LayoutFunc
- type Screen
- type ShutdownFunc
- type StartupFunc
- type Time
- type UpdateFunc
- type Window
Constants ¶
View Source
const ( PngAssetType = "png" JpgAssetType = "jpg" JpegAssetType = "jpeg" BmpAssetType = "bmp" )
View Source
const MaxFixedFrames = 5
Variables ¶
View Source
var ( ErrAssetManagerNotFound = errors.New("asset manager not found") ErrAssetManagerConflict = errors.New("asset manager conflict") ErrAssetManagerNil = errors.New("asset manager is nil") ErrAssetFilesystemConflict = errors.New("asset filesystem conflict") ErrAssetFilesystemNil = errors.New("asset filesystem is nil") ErrAssetInvalidType = errors.New("asset has invalid type") ErrAssetTypeMismatch = errors.New("asset type mismatch") ErrAssetNotLoaded = errors.New("asset not loaded") ErrAssetIsLoaded = errors.New("asset is already loaded") ErrAssetIsLoading = errors.New("asset is currently loading") ErrAssetTypeEmpty = errors.New("asset type is empty") ErrAssetRootEmpty = errors.New("asset root is empty") )
Functions ¶
func HasAssetTypeSupport ¶ added in v0.0.2
func LoadAssets ¶
func MustGetAsset ¶
func MustGetImage ¶ added in v0.0.6
func MustLoadAssets ¶
func MustLoadAssets(files ...AssetFile)
func MustUnloadAssets ¶
func MustUnloadAssets(files ...AssetFile)
func RegisterAssetImporter ¶ added in v0.0.7
func RegisterAssetImporter(manager *AssetImporter) error
func RegisterImageAssetImport ¶ added in v0.0.8
func RegisterImageAssetImport()
func UnloadAssets ¶
Types ¶
type App ¶
type App struct {
DrawFn DrawFunc
LayoutFn LayoutFunc
UpdateFn UpdateFunc
FixedUpdateFn UpdateFunc
LateUpdateFn UpdateFunc
StartupFn StartupFunc
ShutdownFn ShutdownFunc
// contains filtered or unexported fields
}
func NewAppWithContext ¶
func (*App) WithFixedUpdate ¶
func (a *App) WithFixedUpdate(fixedUpdateFunc UpdateFunc) *App
func (*App) WithLateUpdate ¶
func (a *App) WithLateUpdate(lateUpdateFunc UpdateFunc) *App
func (*App) WithLayout ¶
func (a *App) WithLayout(layoutFunc LayoutFunc) *App
func (*App) WithShutdown ¶
func (a *App) WithShutdown(shutdownFunc ShutdownFunc) *App
func (*App) WithStartup ¶
func (a *App) WithStartup(startupFunc StartupFunc) *App
func (*App) WithUpdate ¶
func (a *App) WithUpdate(updateFunc UpdateFunc) *App
func (*App) WithWindow ¶
type AssetAllocator ¶
AssetAllocator is a function that takes raw asset data and converts it into a usable form.
type AssetDeallocator ¶
AssetDeallocator is a function that takes a loaded asset and frees its resources.
type AssetFile ¶
type AssetFile string
AssetFile is a handle to an asset file and its associated type and data.
func (AssetFile) MustUnload ¶
func (f AssetFile) MustUnload()
type AssetImporter ¶ added in v0.0.8
type AssetImporter struct {
ProcessAssetFile AssetAllocator
CleanupAssetFile AssetDeallocator
AssetTypes []AssetType
}
AssetImporter manages allocation and deallocation of a specific asset types.
type AssetType ¶
type AssetType string
AssetType represents the type of an asset, typically derived from its file extension.
type Context ¶
type ContextKey ¶
type ContextKey string
type LayoutFunc ¶
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen represents the game's screen with width and height.
Game logic should reference this to get the current screen dimensions.
func (*Screen) IsFullscreen ¶
func (*Screen) RenderScale ¶
func (*Screen) TargetHeight ¶
func (*Screen) TargetWidth ¶
type ShutdownFunc ¶
type ShutdownFunc func(ctx Context)
type StartupFunc ¶
type StartupFunc func(ctx Context)
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
func (*Time) DeltaMilli ¶
func (*Time) DeltaSeconds ¶
func (*Time) FixedFrames ¶
func (*Time) FixedMilli ¶
func (*Time) FixedSeconds ¶
type UpdateFunc ¶
type UpdateFunc func(ctx Context)
Click to show internal directories.
Click to hide internal directories.