particles

package module
v0.0.0-...-db30525 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 6 Imported by: 0

README

Particle System for Engo engine

Documentation

See GoDoc or have a look at the example folder. if you have any questions, you could reach me on the engo gitter chat.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	// DisableSpawning stops the particle source from emitting new particles
	DisableSpawning bool
	// RemoveWhenDead removes the entity from the world, once all particles are dead.
	RemoveWhenDead bool
	// Effect descripes the particle effect.
	Effect *Effect
}

Component holds the values for an particle emitting entity

func (*Component) GetParticleComponent

func (pc *Component) GetParticleComponent() *Component

type EasingFn

type EasingFn func(t float32) float32

EasingFn takes a value between 0 and 1 and should return a value between 0 and 1

var (
	// Linear easing
	Linear EasingFn = linearEasing

	// InQuad is an increasing quadratic easing function
	InQuad EasingFn = inQuadEasing

	// OutQuad is an decreasing quadratic easing function
	OutQuad EasingFn = outQuadEasing
)

type Effect

type Effect struct {
	MaxParticles                             uint
	ParticleEmitRate                         float32
	MaxLife, MinLife                         float32
	StartSize, EndSize                       engo.Point
	SizeEasing                               EasingFn
	StartColor, EndColor                     color.Color
	ColorEasing                              EasingFn
	StartTranslation                         OffsetFn
	StartVelocity                            OffsetFn
	Acceleration                             engo.Point
	MaxRotation, MinRotation                 float32
	MaxRotationVelocity, MinRotationVelocity float32
	Drawable                                 common.Drawable
	Shader                                   common.Shader
}

Effect descripes a particle effect and can be reused by multiple particle emitting entities.

type OffsetFn

type OffsetFn func() engo.Point

OffsetFn should return an offset for calculating start velocity or start translation

func OffsetInRect

func OffsetInRect(x1, y1, x2, y2 float32) OffsetFn

OffsetInRect returns an OffsetFn which returns a random Point in the given range.

type ParticleFace

type ParticleFace interface {
	GetParticleComponent() *Component
}

type ParticleSource

type ParticleSource interface {
	common.BasicFace
	common.SpaceFace
	ParticleFace
}

type System

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

func (*System) Add

func (ps *System) Add(basic *ecs.BasicEntity, space *common.SpaceComponent, particle *Component)

Add adds an entity to the particle system.

func (*System) AddByInterface

func (ps *System) AddByInterface(i ecs.Identifier)

AddByInterface adds any ParticleSource to the particle system.

func (*System) AddEntity

func (ps *System) AddEntity(i ecs.Identifier)

AddEntity adds an entity to the System. This is much like the AddByInterface but it checks if the type matches.

func (*System) New

func (ps *System) New(w *ecs.World)

New initializes the System

func (*System) Remove

func (ps *System) Remove(e ecs.BasicEntity)

Remove from System interface

func (*System) Update

func (ps *System) Update(dt float32)

Update emits and updates the particles.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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