engine

package
v0.0.0-...-109f979 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Epsilon = 0.00001
	Epsilon = 0.00001 // ~32 bits

	// DegreeToRadians converts to radians, for example, 45.0 * DegreeToRadians = radians
	DegreeToRadians = math.Pi / 180.0
)
View Source
const (
	// M00 XX: Typically the unrotated X component for scaling, also the cosine of the
	// angle when rotated on the Y and/or Z axis. On
	// Vector3 multiplication this value is multiplied with the source X component
	// and added to the target X component.
	M00 = 0
	// M01 XY: Typically the negative sine of the angle when rotated on the Z axis.
	// On Vector3 multiplication this value is multiplied
	// with the source Y component and added to the target X component.
	M01 = 4
	// M02 XZ: Typically the sine of the angle when rotated on the Y axis.
	// On Vector3 multiplication this value is multiplied with the
	// source Z component and added to the target X component.
	M02 = 8
	// M03 XW: Typically the translation of the X component.
	// On Vector3 multiplication this value is added to the target X component.
	M03 = 12

	// M10 YX: Typically the sine of the angle when rotated on the Z axis.
	// On Vector3 multiplication this value is multiplied with the
	// source X component and added to the target Y component.
	M10 = 1
	// M11 YY: Typically the unrotated Y component for scaling, also the cosine
	// of the angle when rotated on the X and/or Z axis. On
	// Vector3 multiplication this value is multiplied with the source Y
	// component and added to the target Y component.
	M11 = 5
	// M12 YZ: Typically the negative sine of the angle when rotated on the X axis.
	// On Vector3 multiplication this value is multiplied
	// with the source Z component and added to the target Y component.
	M12 = 9
	// M13 YW: Typically the translation of the Y component.
	// On Vector3 multiplication this value is added to the target Y component.
	M13 = 13

	// M20 ZX: Typically the negative sine of the angle when rotated on the Y axis.
	// On Vector3 multiplication this value is multiplied
	// with the source X component and added to the target Z component.
	M20 = 2
	// M21 ZY: Typical the sine of the angle when rotated on the X axis.
	// On Vector3 multiplication this value is multiplied with the
	// source Y component and added to the target Z component.
	M21 = 6
	// M22 ZZ: Typically the unrotated Z component for scaling, also the cosine of the
	// angle when rotated on the X and/or Y axis.
	// On Vector3 multiplication this value is multiplied with the source Z component
	// and added to the target Z component.
	M22 = 10
	// M23 ZW: Typically the translation of the Z component.
	// On Vector3 multiplication this value is added to the target Z component.
	M23 = 14

	// M30 WX: Typically the value zero. On Vector3 multiplication this value is ignored.
	M30 = 3
	// M31 WY: Typically the value zero. On Vector3 multiplication this value is ignored.
	M31 = 7
	// M32 WZ: Typically the value zero. On Vector3 multiplication this value is ignored.
	M32 = 11
	// M33 WW: Typically the value one. On Vector3 multiplication this value is ignored.
	M33 = 15
)
View Source
const (
	MaxTranformedVertices = 100
)

Variables

View Source
var AffinePool = NewAffineTransformPool(100)

AffinePool is a pool of transforms

View Source
var VectorsPool = NewVectorPool(100)

VectorsPool is a pool of transforms

Functions

func AffineTransformEqualToTransform

func AffineTransformEqualToTransform(t1, t2 *AffineTransform) bool

Return true if `t1' and `t2' are equal, false otherwise.

func AffineTransformInvert

func AffineTransformInvert(t *AffineTransform, out *AffineTransform)

func AffineTransformInvertTo

func AffineTransformInvertTo(t, to *AffineTransform)

*

  • Invert [t] to [to].

func AffineTransformMultiply

func AffineTransformMultiply(t1 *AffineTransform, t2 *AffineTransform, out *AffineTransform)

*

  • Concatenate `t2' to `t1' and return the result: t' = t1 * t2
  • returns a [Poolable]ed AffineTransform.

func AffineTransformMultiplyFrom

func AffineTransformMultiplyFrom(tA, tB *AffineTransform)

*

func AffineTransformMultiplyTo

func AffineTransformMultiplyTo(tA, tB *AffineTransform)

*

  • Multiply [tA] x [tB] and place in [tB]

func AffineTransformRotate

func AffineTransformRotate(t *AffineTransform, out *AffineTransform, anAngle float64)

*

  • Rotation is just a matter of perspective. A CW rotation can be seen as
  • CCW depending on what you are talking about rotating. For example,
  • if the coordinate system is thought as rotating CCW then objects are
  • seen as rotating CW. And that is what the 2x2 matrix below represents
  • with Canvas2D.
  • |cos -sin| object appears to rotate CW.
  • |sin cos| *
  • In the matrix below the object appears to rotate CCW.
  • |cos sin|
  • |-sin cos| *
  • |a c| |cos -sin|
  • |b d| x |sin cos| *

func AffineTransformScale

func AffineTransformScale(t *AffineTransform, out *AffineTransform, sx, sy float64)

func AffineTransformTranslate

func AffineTransformTranslate(t *AffineTransform, out *AffineTransform, tx, ty float64)

func CompApplyAffineTransformTo

func CompApplyAffineTransformTo(x, y float64, out *Vector3, t *AffineTransform)

func Distance

func Distance(x1, y1, z1, x2, y2, z2 float64) float64

Distance finds the euclidean distance between the two specified vectors

func DistanceSquared

func DistanceSquared(x1, y1, z1, x2, y2, z2 float64) float64

DistanceSquared finds the euclidean distance between the two specified vectors squared

func Dot

func Dot(x1, y1, z1, x2, y2, z2 float64) float64

Dot returns the product between the two vectors

func DrawRect

func DrawRect(x, y float64, w, h int, centered bool, color color.RGBA, pixels *image.RGBA)

DrawRect renderers a rectangle

func Length

func Length(x, y, z float64) float64

Length returns the euclidean length

func LengthSquared

func LengthSquared(x, y, z float64) float64

LengthSquared returns the euclidean length squared

func Lerp

func Lerp(x1, y1, y float64) float64

Lerp is basic linear mapping

func LinearEasing

func LinearEasing(timePosition, startValue, deltaValue, duration float64) float64

LinearEasing is a basic linear lerp t,b,c,d timePosition ranges from 0 to duration

func Multiply

func Multiply(a, b, out *Matrix4)

Multiply multiplies a * b and places result into 'out', (i.e. out = a * b)

func MultiplyIntoA

func MultiplyIntoA(a, b *Matrix4)

MultiplyIntoA multiplies a * b and places result into 'a', (i.e. a = a * b)

Types

type AffineTransform

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

*

  • A minified affine transform.
  • column major (form used by this class)
  • x' |a c tx| |x|
  • y' = |b d ty| |y|
  • 1 |0 0 1| |1|
  • or
  • Row major
  • |a b 0|
  • |x' y' 1| = |x y 1| x |c d 0|
  • |tx ty 1| *

func NewAffineTransform

func NewAffineTransform() *AffineTransform

func (*AffineTransform) ApplyTo

func (at *AffineTransform) ApplyTo(point *Vector3, out *Vector3)

func (*AffineTransform) ApplyToVector

func (at *AffineTransform) ApplyToVector(point *Vector3, out *Vector3)

func (*AffineTransform) AsScale

func (at *AffineTransform) AsScale(sx, sy float64) *AffineTransform

func (*AffineTransform) AsTranslate

func (at *AffineTransform) AsTranslate(tx, ty float64) *AffineTransform

func (*AffineTransform) Invert

func (at *AffineTransform) Invert()

func (*AffineTransform) Multiply

func (at *AffineTransform) Multiply(t1, t2 *AffineTransform)

func (*AffineTransform) PreMultiply

func (at *AffineTransform) PreMultiply(t *AffineTransform)

*

  • A pre multiply order.

func (*AffineTransform) Rotate

func (at *AffineTransform) Rotate(angle float64)

*

  • Concatinate a rotation (radians) onto this transform. *
  • Rotation is just a matter of perspective. A CW rotation can be seen as
  • CCW depending on what you are talking about rotating. For example,
  • if the coordinate system is thought as rotating CCW then objects are
  • seen as rotating CW, and that is what the 2x2 matrix below represents
  • with Canvas2D. It is also the frame of reference we use.
  • |cos -sin| object appears to rotate CW.
  • |sin cos| *
  • In the matrix below the object appears to rotate CCW.
  • |cos sin|
  • |-sin cos| *
  • |a c| |cos -sin|
  • |b d| x |sin cos| *

func (*AffineTransform) Scale

func (at *AffineTransform) Scale(sx, sy float64)

/ Concatenate scale

func (*AffineTransform) Set

func (at *AffineTransform) Set(a, b, c, d, tx, ty float64)

func (*AffineTransform) SetToRotate

func (at *AffineTransform) SetToRotate(angle float64)

If Y axis is downward (default for SDL and Image) then: +angle yields a CW rotation -angle yeilds a CCW rotation.

else -angle yields a CW rotation +angle yeilds a CCW rotation.

func (*AffineTransform) SetToScale

func (at *AffineTransform) SetToScale(sx, sy float64)

func (*AffineTransform) SetToTranslate

func (at *AffineTransform) SetToTranslate(tx, ty float64)

func (*AffineTransform) SetWithAT

func (at *AffineTransform) SetWithAT(t *AffineTransform)

func (*AffineTransform) Skew

func (at *AffineTransform) Skew(x, y float64)

*

  • A minified affine transform.
  • |a c tx|
  • |b d ty|
  • |0 0 1| *
  • |- y -|
  • |x - -|
  • |0 0 1|

/ Concatenate skew/shear / [x] and [y] are in radians

func (AffineTransform) String

func (v AffineTransform) String() string

*

  • |a c tx| |cos -sin|
  • |b d ty| |sin cos|

func (*AffineTransform) ToIdentity

func (at *AffineTransform) ToIdentity()

---------------------------------------------------------- Methods ----------------------------------------------------------

func (*AffineTransform) Translate

func (at *AffineTransform) Translate(x, y float64)

/ Concatenate translation

func (*AffineTransform) Transpose

func (at *AffineTransform) Transpose()

*

  • Converts either from or to pre or post multiplication.
  • a c
  • b d
  • to
  • a b
  • c d

type AffineTransformPool

type AffineTransformPool []*AffineTransform

AffineTransformPool is a pool of AffineTransforms

func NewAffineTransformPool

func NewAffineTransformPool(count int) AffineTransformPool

NewAffineTransformPool creates and adds transforms to the pool

func (*AffineTransformPool) Add

func (q *AffineTransformPool) Add(count int)

Add populates the pool with a fixed size

func (*AffineTransformPool) IsEmpty

func (q *AffineTransformPool) IsEmpty() bool

IsEmpty is true if pool is empty

func (*AffineTransformPool) Pop

func (q *AffineTransformPool) Pop() (n *AffineTransform)

Pop pulls a transform from the pool.

func (*AffineTransformPool) Push

Push puts a transform into the pool

type BaseNode

type BaseNode struct {
	SolidColor color.RGBA
	// contains filtered or unexported fields
}

func (*BaseNode) Initialize

func (n *BaseNode) Initialize()

func (*BaseNode) IsVisible

func (n *BaseNode) IsVisible() bool

func (*BaseNode) Name

func (n *BaseNode) Name() string

func (*BaseNode) Position

func (n *BaseNode) Position() *Vector3

func (*BaseNode) Render

func (n *BaseNode) Render(context *RenderContext)

Render node

func (*BaseNode) Rotation

func (n *BaseNode) Rotation() float64

func (*BaseNode) Scale

func (n *BaseNode) Scale() *Vector3

func (*BaseNode) SetColor

func (n *BaseNode) SetColor(color color.RGBA)

func (*BaseNode) SetInvisible

func (n *BaseNode) SetInvisible()

func (*BaseNode) SetName

func (n *BaseNode) SetName(s string)

func (*BaseNode) SetPosition

func (n *BaseNode) SetPosition(v *Vector3)

func (*BaseNode) SetPositionBy2Comp

func (n *BaseNode) SetPositionBy2Comp(x, y float64)

func (*BaseNode) SetRotation

func (n *BaseNode) SetRotation(angle float64)

+angle yields CW rotation

func (*BaseNode) SetRotationByDegree

func (n *BaseNode) SetRotationByDegree(angle float64)

+angle yields CW rotation

func (*BaseNode) SetScale

func (n *BaseNode) SetScale(v *Vector3)

func (*BaseNode) SetScaleUniform

func (n *BaseNode) SetScaleUniform(s float64)

func (*BaseNode) SetVisible

func (n *BaseNode) SetVisible()

func (BaseNode) String

func (n BaseNode) String() string

func (*BaseNode) Update

func (n *BaseNode) Update(dt float64)

Update node

type Drawer

type Drawer func(*RenderContext)

type DynaText

type DynaText struct {
	Color sdl.Color

	X      int32
	Y      int32
	Width  int32
	Height int32
	// contains filtered or unexported fields
}

DynaText represents dynamically changing text. The text is broken down into characters and each character is rendered using an existing character atlas. This is a base class for dynamic text.

func NewDynaText

func NewDynaText(font *Font, renderer *sdl.Renderer, color sdl.Color) *DynaText

NewDynaText creates a Text object.

func (*DynaText) Destroy

func (t *DynaText) Destroy()

Destroy closes the Text

func (*DynaText) Draw

func (t *DynaText) Draw(text string)

Draw renders text

func (*DynaText) DrawAt

func (t *DynaText) DrawAt(x, y int32, text string)

DrawAt renders text at the specified position

type Element

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

type Engine

type Engine struct {
	Width  int32
	Height int32

	ClearColor color.RGBA
	// contains filtered or unexported fields
}

Engine is the GUI and shell

func NewEngine

func NewEngine(width, height int32) *Engine

NewEngine creates a new engine and initializes it.

func (*Engine) Close

func (v *Engine) Close()

Close releases resources and shutsdown the engine. Be sure to setup a "defer x.Close()"

func (*Engine) Configure

func (v *Engine) Configure()

Configure view with draw objects

func (*Engine) GetRoot

func (v *Engine) GetRoot() IGroupNode

func (*Engine) Initialize

func (v *Engine) Initialize(title string)

func (*Engine) Quit

func (v *Engine) Quit()

Quit stops the engine from running, effectively shutting it down.

func (*Engine) Run

func (v *Engine) Run()

Run starts the polling event loop. This must run on the main thread.

func (*Engine) SetFont

func (v *Engine) SetFont(fontPath string, size int) error

SetFont sets the font based on path and size.

func (*Engine) SetRoot

func (v *Engine) SetRoot(n *GroupNode)

func (*Engine) Start

func (v *Engine) Start(game Game)

Start shows the display and begins event polling

type Font

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

Font wraps the SDL TTF fonts.

func NewFont

func NewFont(fontPath string, size int) (*Font, error)

NewFont creates a Font object: Ex NewFont("neuropol x rg.ttf", 16)

func (*Font) Destroy

func (f *Font) Destroy()

Destroy closes the font

type Game

type Game interface {
	Update(float64, []uint8)
	Render(*image.RGBA)
}

Game should be implemented by the developer

type GroupNode

type GroupNode struct {
	BaseNode // is-a
	// contains filtered or unexported fields
}

GroupNode is a collection of nodes

func (*GroupNode) Add

func (gn *GroupNode) Add(n INode)

func (*GroupNode) Draw

func (gn *GroupNode) Draw(context *RenderContext)

func (*GroupNode) Find

func (gn *GroupNode) Find(n INode) (f int, fno INode)

func (*GroupNode) Remove

func (gn *GroupNode) Remove(n INode)

func (*GroupNode) Render

func (gn *GroupNode) Render(context *RenderContext)

func (*GroupNode) Update

func (gn *GroupNode) Update(dt float64)

type IGroupNode

type IGroupNode interface {
	INode
	Add(n INode) // Last node added is render underneath
	Remove(n INode)
	Find(n INode) (f int, fno INode)
}

func NewGroupNode

func NewGroupNode(parent IGroupNode, autoAdd bool) IGroupNode

type INode

type INode interface {
	Update(dt float64)
	Render(context *RenderContext)

	Position() *Vector3
	SetPosition(*Vector3)
	SetPositionBy2Comp(x, y float64)

	Scale() *Vector3
	SetScale(*Vector3)
	SetScaleUniform(float64)

	Rotation() float64
	SetRotation(float64)
	SetRotationByDegree(float64)

	SetInvisible()
	SetVisible()
	IsVisible() bool

	SetColor(color.RGBA)
	Name() string
	SetName(string)

	String() string
	// contains filtered or unexported methods
}

Node is the base node.

func NewRectangleNode

func NewRectangleNode(parent IGroupNode, centered, autoAdd bool) INode

type Matrix4

type Matrix4 struct {

	// Rotation is in radians
	Rotation float64
	Scale    Vector3
	// contains filtered or unexported fields
}

Matrix4 represents a column major opengl array.

func NewMatrix4

func NewMatrix4() *Matrix4

NewMatrix4 creates a Matrix4 initialized to an identity matrix

func (*Matrix4) C

func (m *Matrix4) C(i int) float64

C returns a cell value based on Mxx index

func (*Matrix4) Clone

func (m *Matrix4) Clone() *Matrix4

Clone returns a clone of this matrix

func (*Matrix4) GetScale

func (m *Matrix4) GetScale(out *Vector3)

GetScale returns the scale in 'out' field.

func (*Matrix4) GetTranslation

func (m *Matrix4) GetTranslation(out *Vector3)

GetTranslation returns the translational components in 'out' Vector3 field.

func (*Matrix4) Multiply

func (m *Matrix4) Multiply(a, b *Matrix4)

Multiply multiplies a * b and places result into this matrix, (i.e. this = a * b)

func (*Matrix4) PostMultiply

func (m *Matrix4) PostMultiply(b *Matrix4)

PostMultiply postmultiplies 'b' matrix with 'this' and places the result into 'this' matrix. (i.e. this = this * b)

func (*Matrix4) PostScale

func (m *Matrix4) PostScale(sx, sy, sz float64) *Matrix4

PostScale postmultiplies this matrix with a scale matrix.

func (*Matrix4) PostTranslate

func (m *Matrix4) PostTranslate(tx, ty, tz float64) *Matrix4

PostTranslate postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES.

func (*Matrix4) PreMultiply

func (m *Matrix4) PreMultiply(b *Matrix4)

PreMultiply premultiplies 'b' matrix with 'this' and places the result into 'this' matrix. (i.e. this = b * this)

func (*Matrix4) RotateBy

func (m *Matrix4) RotateBy(angle float64) *Matrix4

RotateBy postmultiplies this matrix with a (counter-clockwise) rotation matrix whose angle is specified in radians.

func (*Matrix4) ScaleBy

func (m *Matrix4) ScaleBy(v *Vector3) *Matrix4

ScaleBy scales the scale components.

func (*Matrix4) Set

func (m *Matrix4) Set(src *Matrix4) *Matrix4

Set copies src into this matrix

func (*Matrix4) SetRotation

func (m *Matrix4) SetRotation(angle float64) *Matrix4

SetRotation set a rotation matrix about Z axis. 'angle' is specified in radians.

[  M00  M01   _    _   ]
[  M10  M11   _    _   ]
[   _    _    _    _   ]
[   _    _    _    _   ]

func (*Matrix4) SetScale

func (m *Matrix4) SetScale(v *Vector3) *Matrix4

SetScale sets the scale components of an identity matrix and captures scale values into Scale property.

func (*Matrix4) SetScale2Comp

func (m *Matrix4) SetScale2Comp(sx, sy float64) *Matrix4

SetScale2Comp sets the scale components of an identity matrix and captures scale values into Scale property where Z component = 1.0.

func (*Matrix4) SetScale3Comp

func (m *Matrix4) SetScale3Comp(sx, sy, sz float64) *Matrix4

SetScale3Comp sets the scale components of an identity matrix and captures scale values into Scale property.

func (*Matrix4) SetToOrtho

func (m *Matrix4) SetToOrtho(left, right, bottom, top, near, far float64) *Matrix4

SetToOrtho sets the matrix for a 2d ortho graphic projection

func (*Matrix4) SetTranslate3Comp

func (m *Matrix4) SetTranslate3Comp(x, y, z float64) *Matrix4

SetTranslate3Comp sets the translational component to the matrix in the 4th column. The other columns are unmodified.

func (*Matrix4) SetTranslateByVector

func (m *Matrix4) SetTranslateByVector(v *Vector3) *Matrix4

SetTranslateByVector sets the translational component to the matrix in the 4th column. The other columns are unmodified.

func (Matrix4) String

func (m Matrix4) String() string

func (*Matrix4) ToIdentity

func (m *Matrix4) ToIdentity()

ToIdentity set this matrix to the identity matrix

func (*Matrix4) TranslateBy

func (m *Matrix4) TranslateBy(v *Vector3) *Matrix4

TranslateBy adds a translational component to the matrix in the 4th column. The other columns are unmodified.

func (*Matrix4) TranslateBy2Comps

func (m *Matrix4) TranslateBy2Comps(x, y float64) *Matrix4

TranslateBy2Comps adds a translational component to the matrix in the 4th column. Z is unmodified. The other columns are unmodified.

func (*Matrix4) TranslateBy3Comps

func (m *Matrix4) TranslateBy3Comps(x, y, z float64) *Matrix4

TranslateBy3Comps adds a translational component to the matrix in the 4th column. The other columns are unmodified.

type Particle

type Particle struct {
	Position *Vector3
	Velocity *Vector3

	// How long a particle lives after activation.
	Duration float64

	// Colors are lerped
	StartColor, EndColor color.RGBA
	RenderColor          color.RGBA

	IsAlive bool
	// contains filtered or unexported fields
}

Particle is a single particle

func NewParticle

func NewParticle() *Particle

NewParticle creates a new particle at 0,0 and white.

func (*Particle) Update

func (ps *Particle) Update(dt float64)

Update modifies a particle's particles.

type ParticleSystem

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

ParticleSystem is a bunch of particles.

func NewParticleSystem

func NewParticleSystem(count int, renderer RenderParticle, triggerer TriggerParticle) *ParticleSystem

NewParticleSystem creates a particle system

func (*ParticleSystem) Initialize

func (ps *ParticleSystem) Initialize(count int)

Initialize creates particles

func (*ParticleSystem) Render

func (ps *ParticleSystem) Render(pixels *image.RGBA)

Render draws a particle using the "renderer" callback.

func (*ParticleSystem) TriggerParticle

func (ps *ParticleSystem) TriggerParticle()

TriggerParticle activates a single particle

func (*ParticleSystem) Update

func (ps *ParticleSystem) Update(dt float64)

Update processes all particles.

type RectangleNode

type RectangleNode struct {
	BaseNode // is-a
	// contains filtered or unexported fields
}

func (*RectangleNode) Draw

func (n *RectangleNode) Draw(context *RenderContext)

func (*RectangleNode) Render

func (n *RectangleNode) Render(context *RenderContext)

func (*RectangleNode) Update

func (n *RectangleNode) Update(dt float64)

type RenderContext

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

RenderContext is a rendering context

func NewRenderContext

func NewRenderContext(image *image.RGBA) *RenderContext

func (*RenderContext) DrawPolygon

func (c *RenderContext) DrawPolygon(vertices []*Vector3, color color.RGBA)

func (*RenderContext) RenderContext

func (c *RenderContext) RenderContext() *gg.Context

func (*RenderContext) Restore

func (c *RenderContext) Restore()

func (*RenderContext) Save

func (c *RenderContext) Save()

func (*RenderContext) Set

func (c *RenderContext) Set(at *AffineTransform)

func (*RenderContext) Transform

func (c *RenderContext) Transform(at *AffineTransform)

func (*RenderContext) TransformContext

func (c *RenderContext) TransformContext() *AffineTransform

type RenderParticle

type RenderParticle func(particle *Particle, pixels *image.RGBA)

RenderParticle implemented by developer to render a single particle.

type Stack

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

func NewStack

func NewStack(max int) *Stack

func (*Stack) Len

func (s *Stack) Len() int

Return the stack's length

func (*Stack) Max

func (s *Stack) Max() int

Return the stack's max

func (*Stack) Peek

func (s *Stack) Peek() (value interface{}, exists bool)

Peek returns a top without removing it from list

func (*Stack) Pop

func (s *Stack) Pop() (value interface{})

Remove the top element from the stack and return it's value If the stack is empty, return nil

func (*Stack) PopLast

func (s *Stack) PopLast() (value interface{})

func (*Stack) Push

func (s *Stack) Push(value interface{})

Push a new element onto the stack

type Text

type Text struct {
	Bounds sdl.Rect
	// contains filtered or unexported fields
}

Text represents a text texture for rendering.

func NewText

func NewText(font *Font, renderer *sdl.Renderer) *Text

NewText creates a Text object.

func (*Text) Destroy

func (t *Text) Destroy() error

Destroy closes the Text

func (*Text) Draw

func (t *Text) Draw()

Draw renders text

func (*Text) DrawAt

func (t *Text) DrawAt(x, y int32)

DrawAt renders text

func (*Text) SetText

func (t *Text) SetText(text string, color sdl.Color) (err error)

SetText builds an SDL texture. Be sure to call Destroy before program exit.

type TriggerParticle

type TriggerParticle func(particle *Particle, system *ParticleSystem)

TriggerParticle activates a particle defined by developer.

type Vector3

type Vector3 struct {
	X, Y, Z float64
}

Vector3 contains base components

func CompApplyAffineTransform

func CompApplyAffineTransform(x, y float64, t *AffineTransform) *Vector3

func NewVector3

func NewVector3() *Vector3

NewVector3 creates a Vector3 initialized to 0.0, 0.0, 0.0

func NewVector3With2Components

func NewVector3With2Components(x, y float64) *Vector3

NewVector3With2Components creates a Vector3 initialized with x,y and z = 0.0

func NewVector3With3Components

func NewVector3With3Components(x, y, z float64) *Vector3

NewVector3With3Components creates a Vector3 initialized with x,y,z

func PointApplyAffineTransform

func PointApplyAffineTransform(point *Vector3, t *AffineTransform) *Vector3

func (*Vector3) Add

func (v *Vector3) Add(src *Vector3) *Vector3

Add a Vector3 to this vector

func (*Vector3) Add2Components

func (v *Vector3) Add2Components(x, y float64) *Vector3

Add2Components adds x and y to this vector

func (*Vector3) Clone

func (v *Vector3) Clone() *Vector3

Clone returns a new copy this vector

func (*Vector3) Cross

func (v *Vector3) Cross(o *Vector3) *Vector3

Cross sets this vector to the cross product between it and the other vector.

func (*Vector3) Distance

func (v *Vector3) Distance(src *Vector3) float64

Distance finds the euclidean distance between the two specified vectors

func (*Vector3) DistanceSquared

func (v *Vector3) DistanceSquared(src *Vector3) float64

DistanceSquared finds the euclidean distance between the two specified vectors squared

func (*Vector3) DivScalar

func (v *Vector3) DivScalar(scale float64)

DivScalar 1/scales this vector

func (*Vector3) Dot

func (v *Vector3) Dot(o *Vector3) float64

Dot returns the product between the two vectors

func (*Vector3) DotByComponent

func (v *Vector3) DotByComponent(x, y, z float64) float64

DotByComponent returns the product between the two vectors

func (*Vector3) EqEpsilon

func (v *Vector3) EqEpsilon(other *Vector3) bool

EqEpsilon makes an approximate equality check. Preferred

func (*Vector3) Equal

func (v *Vector3) Equal(other *Vector3) bool

Equal makes an exact equality check. Use EqEpsilon, it is more realistic.

func (*Vector3) Length

func (v *Vector3) Length() float64

Length returns the euclidean length

func (*Vector3) LengthSquared

func (v *Vector3) LengthSquared() float64

LengthSquared returns the euclidean length squared

func (*Vector3) Mul

func (v *Vector3) Mul(m *Matrix4) *Vector3

Mul left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.

func (*Vector3) MulAdd

func (v *Vector3) MulAdd(src *Vector3, scalar float64) *Vector3

MulAdd scales and adds src to this vector

func (*Vector3) Normalize

func (v *Vector3) Normalize()

Normalize this instance

func (*Vector3) ScaleBy

func (v *Vector3) ScaleBy(s float64) *Vector3

ScaleBy scales this vector by s

func (*Vector3) ScaleBy2Components

func (v *Vector3) ScaleBy2Components(sx, sy float64) *Vector3

ScaleBy2Components scales this vector by sx and sy

func (*Vector3) Set

func (v *Vector3) Set(source *Vector3)

Set modifies x,y,z from source

func (*Vector3) Set2Components

func (v *Vector3) Set2Components(x, y float64)

Set2Components modifies x,y only

func (*Vector3) Set3Components

func (v *Vector3) Set3Components(x, y, z float64)

Set3Components modifies x,y,z

func (Vector3) String

func (v Vector3) String() string

func (*Vector3) Sub

func (v *Vector3) Sub(src *Vector3) *Vector3

Sub subtracts a Vector3 to this vector

func (*Vector3) Sub2Components

func (v *Vector3) Sub2Components(x, y float64) *Vector3

Sub2Components subtracts x and y to this vector

type VectorPool

type VectorPool []*Vector3

VectorPool is a pool of vectors

func NewVectorPool

func NewVectorPool(count int) VectorPool

NewVectorPool creates and adds vectors to the pool

func (*VectorPool) Add

func (q *VectorPool) Add(count int)

Add populates the pool with a fixed size

func (*VectorPool) IsEmpty

func (q *VectorPool) IsEmpty() bool

IsEmpty is true if pool is empty

func (*VectorPool) Pop

func (q *VectorPool) Pop() (n *Vector3)

Pop pulls a transform from the pool.

func (*VectorPool) Push

func (q *VectorPool) Push(n *Vector3)

Push puts a transform into the pool

Jump to

Keyboard shortcuts

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