display

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package display is a set of components to interact with the representation of a entity or it's sprite on screen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimateComponent

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

AnimateComponent is the core way of animating a sprite on screen

func NewAnimateComponent

func NewAnimateComponent(subject subjects.Animateable, frameRate float64, sprites []*ebiten.Image, opts ...AnimateOpt) *AnimateComponent

NewAnimateComponent creates a new AnimateComponent, with reference to the subject

func (*AnimateComponent) CenterImage added in v0.1.5

func (ac *AnimateComponent) CenterImage() *AnimateComponent

CenterImage is the fluent api for setting the image to be centered

func (*AnimateComponent) DisableLoop added in v0.1.5

func (ac *AnimateComponent) DisableLoop(complete func()) *AnimateComponent

DisableLoop is the fluent api for disabling the loop and setting the complete callback

func (*AnimateComponent) Draw

func (ac *AnimateComponent) Draw(screen *ebiten.Image, xOffset, yOffset float64)

Draw draws the current frame to the screen. It takes the screen as well as an X and Y offset. These offsets are not to be confused with the Animateable offset, this offset is for a camera projection. Whereas the Animateable offset is used for differences in the sprites as they are drawn in their source files.

func (*AnimateComponent) Reset

func (ac *AnimateComponent) Reset()

Reset is used to return the current frame index to 0, mostly used when needing to reset a non-looping animation

func (*AnimateComponent) Update

func (ac *AnimateComponent) Update() error

Update is called as a byproduct of the main game loop, this will update the animation according to the frame rate. Will handle non-looping animations.

type AnimateOpt

type AnimateOpt func(ac *AnimateComponent)

AnimateOpt is a func for modifying an animate component

func AnimateCenterImage

func AnimateCenterImage() AnimateOpt

AnimateCenterImage configures the AnimateComponent to draw with reference to the center and not the top left. This is used to help with flipping horizontally and vertically.

func AnimateDisableLoop

func AnimateDisableLoop(complete func()) AnimateOpt

AnimateDisableLoop turns of the looping for the particular animation.

type FlashComponent added in v0.1.6

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

func NewFlashComponent added in v0.1.6

func NewFlashComponent(subject subjects.Animateable, frameRate float64, sprite *ebiten.Image, totalFlashes int, flashColor color.Color) *FlashComponent

func (*FlashComponent) CenterImage added in v0.1.6

func (fc *FlashComponent) CenterImage() *FlashComponent

func (*FlashComponent) DisableLoop added in v0.1.6

func (fc *FlashComponent) DisableLoop(complete func()) *FlashComponent

func (*FlashComponent) Draw added in v0.1.6

func (fc *FlashComponent) Draw(screen *ebiten.Image, xOffset, yOffset float64)

func (*FlashComponent) Reset added in v0.1.6

func (fc *FlashComponent) Reset()

func (*FlashComponent) Update added in v0.1.6

func (fc *FlashComponent) Update() error

Jump to

Keyboard shortcuts

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