figo

package
v0.0.0-...-cf82ea8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FloatToVec

func FloatToVec(out []glm.Vector2, in ...float32) []glm.Vector2

func MinMaxVec

func MinMaxVec(a, b glm.Vector2) (min glm.Vector2, max glm.Vector2)

MinMaxVec will return a pair of vectors hold the smallest (x,y) pair from a and b. And the biggest (x,y) pair from a and b.

TODO: put a example here

min, max := MinMaxVec(glm.Vector2{-1, 10}, glm.Vector2{10, -1})

min == glm.Vector2{-1, -1} max == glm.Vector2{10, 10}

func VecToFloat

func VecToFloat(out []float32, in ...glm.Vector2) []float32

VecToFloat convert a input slice of Vector2 objects to a flat slice of float32 values.

If out is large enough (cap(out) >= len(in)*2) then no allocation is done.

If out is smaller or nil, then a new slice is allocated

Types

type AABB

type AABB struct {
	Min glm.Vector2
	Max glm.Vector2
}

A axis-aligned bounding box

func NewAABB

func NewAABB(minX, minY, maxX, maxY float32) AABB

func (*AABB) MergeWith

func (a *AABB) MergeWith(other *AABB)

MergeWith will expand this AABB to contain the other AABB

func (*AABB) Set

func (a *AABB) Set(minX, minY, maxX, maxY float32)

type Body

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

Body is a collection of shapes that have their vertices kept in a solid formation

Ie, Body is a RigidBody

func NewBody

func NewBody() *Body

func (*Body) AddShape

func (b *Body) AddShape(s *Shape) *Body

AddShape inserts a new shape to this body.

This will force the body bounding rect to be recalculated

func (*Body) BoundRect

func (b *Body) BoundRect() AABB

BoundRect returns the axis aligned bouding rectangle for this body.

The returned rectanble is large enough to hold all shapes that form this body

type DebugDraw

type DebugDraw interface {
	// BeginFrame is called to signal the start of a new frame
	BeginFrame(frame FrameData)
	// EndFrame is called to signal the end of the last frame
	EndFrame(frame FrameData)
	// DrawShape should the given shape
	//
	// If velocity != 0 the shape is moving
	// If accel != 0 the shape is moving and accelerating
	// If mass != 0 the shape is solid
	DrawShape(s *Shape, mass, velocity, accel float32)
}

DebugDraw group a small number of functions used by the figo engine to give a visual representation of the world at the given state

type FrameData

type FrameData struct {
	// The fixed delta used in the engine
	FixedDelta float32
	// The time elapsed from the last frame
	Delta float32
	// The number of this frame
	Number uint

	// Half of the world width
	HalfWidth float32

	// Half of the world height
	HalfHeight float32
}

Hold information to identify the given frame

type Shape

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

func NewPolygonShape

func NewPolygonShape(points ...glm.Vector2) *Shape

NewPolygonShape will copy all vertices from points to this shape.

func NewRectShape

func NewRectShape(halfSize glm.Vector2) *Shape

NewRectShape create a new Shape and In this function you should provide half of the final size, if you give (1,1) you get a box of (2,2).

X and Y don't need to be equal

Vertex information is set clockwise.

func (*Shape) AABB

func (s *Shape) AABB() AABB

func (*Shape) Clone

func (s *Shape) Clone() *Shape

func (*Shape) Origin

func (s *Shape) Origin() glm.Vector2

func (*Shape) Position

func (s *Shape) Position() glm.Vector2

func (*Shape) Rotation

func (s *Shape) Rotation() float32

func (*Shape) Scale

func (s *Shape) Scale() glm.Vector2

func (*Shape) SetOrigin

func (s *Shape) SetOrigin(origin glm.Vector2)

func (*Shape) SetPosition

func (s *Shape) SetPosition(pos glm.Vector2)

func (*Shape) SetRotation

func (s *Shape) SetRotation(rot float32)

func (*Shape) SetScale

func (s *Shape) SetScale(scale glm.Vector2)

func (*Shape) String

func (s *Shape) String() string

func (*Shape) TransformedVertices

func (s *Shape) TransformedVertices() []float32

func (*Shape) Translate

func (s *Shape) Translate(transf glm.Vector2)

func (*Shape) Vertices

func (s *Shape) Vertices() []float32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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