loading

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

Loading

Loading is a utility scene that preloads images and audio. It can be customized to present an image/feel to get your audience aquainted with you as a creator.

Provides a built in utility format to have a minimum wait time while in production to make sure that players see your creator branding. See wait_dev and wait_prod and their build tags for a deeper glance.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FastLoad bool

FastLoad skips the pesky loading of images and just makes a bunch of empty images When your asset library is large and you just want to test some basic logic.

View Source
var Scene = scene.Scene{
	Start: func(ctx *scene.Context) {
		win := ctx.Window.(*oak.Window)

		ident, err := render.LoadSprite(filepath.Join("assets", "images", "raw", "ident.png"))
		if err == nil {
			ident.Modify(mod.ResizeToFit(400, 400, gift.CubicResampling))
			identw, identh := ident.GetDims()
			ident.SetPos(
				float64(ctx.Window.Width())/2-float64(identw)/2,
				float64(ctx.Window.Height())/2-float64(identh)/2,
			)
			ctx.DrawStack.Draw(ident, layers.StackBackground, layers.Back)
		}

		loadSheet, err := render.LoadSheet(filepath.Join("assets", "images", "32x32", "loading.png"), intgeom.Point2{32, 32})
		if err == nil {
			loadingSeq, err = render.NewSheetSequence(loadSheet, 32, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0)
			loadingSeq.SetPos(float64(ctx.Window.Width()/2)-16, float64(ctx.Window.Height())-64)
			dlog.ErrorCheck(err)

			win.LoadingR = loadingSeq

			go ctx.DoAfter(2*time.Second, func() {

				ctx.DrawStack.Draw(loadingSeq, layers.StackBackground, layers.Back)
			})
		}

		go func() {
			imageFolder := "assets/images"
			if FastLoad {
				dlog.ErrorCheck(render.BlankBatchLoad(imageFolder, 1000*500))
			} else {
				dlog.ErrorCheck(render.BatchLoad(imageFolder))
			}
			loadComplete++
		}()

		go func() {
			if FastLoad {
				audio.BlankBatchLoad(filepath.Join("assets", "audio"))
			} else {
				audio.BatchLoad(filepath.Join("assets", "audio"))
			}

			sound.Init(1, 1, 1)
			loadComplete++
		}()
		go func() {
			waitInProduction(ctx)
			loadComplete++
		}()
	},
	Loop: func() bool {
		return loadComplete < 3
	},
	End: func() (string, *scene.Result) {
		return scenes.Sample, &scene.Result{
			Transition:     scene.Fade(1, 20),
			NextSceneInput: nil,
		}
	},
}

Scene for managing loading and displaying something while we load.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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