Documentation ¶
Index ¶
- Constants
- type Compute
- type IAffineTransform
- type IColor
- type IContactListener
- type IDragging
- type IEngine
- type IEvent
- type IFilter
- type IFilterListener
- type IGroup
- type ILine
- type IMesh
- type IMotion
- type INode
- type INodeList
- type INodeManager
- type IPalette
- type IParticle
- type IParticleActivator
- type IParticleSystem
- type IPoint
- type IPolygon
- type IRasterFont
- type IRectangle
- type IRender
- type IRenderContext
- type IScene
- type ITransform
- type ITransition
- type ITween
- type ITweenEquation
- type IVector
- type IVectorFont
- type IVelocity
- type IWorld
- type IZone
- type IZoneListener
- type IZoomTransform
- type ZoomValue
Constants ¶
const ( // IOTypeKeyboard is a keyboard event IOTypeKeyboard = 0 // IOTypeMouseMotion is a mouse event IOTypeMouseMotion = 1024 // IOTypeMouseButtonDown is a mouse event IOTypeMouseButtonDown = 1025 // IOTypeMouseButtonUp is a mouse event IOTypeMouseButtonUp = 1026 // IOTypeMouseWheel is a mouse event IOTypeMouseWheel = 1027 )
const ( // MaxParticleLifetime is a default lifetime MaxParticleLifetime = 1.0 // MaxParticleSpeed is a good default starting value MaxParticleSpeed = 20.0 )
const ( // FILLED polygon FILLED = 0 // OUTLINED polygon OUTLINED = 1 // FILLOUTLINED both fill and outlined FILLOUTLINED = 2 // CLOSED indicates a polygon should be rendered closed CLOSED = 0 // OPEN indicates a polygon should be rendered open OPEN = 1 )
const ( // SceneNoAction means no action is taken when transitioning SceneNoAction = 0 // SceneReplace ... SceneReplace = 1 // SceneReplaceTake ... SceneReplaceTake = 2 // SceneReplaceTakeUnregister ... SceneReplaceTakeUnregister = 3 )
const ( // EaseNoMeaning indicates that some equations don't have a meaningful // value, for example, Linear EaseNoMeaning = -1 // EaseIn eases in EaseIn = 0 // EaseOut eases out EaseOut = 1 // EaseInOut eases both directions EaseInOut = 2 // EquationLinear Linear equations EquationLinear = 0 // EquationExpo Exponential equations EquationExpo = 1 // EquationQuad Quadratic equations EquationQuad = 2 )
const ( // PTM is Pixels-to-Meters which isn't used in Ranger. It is // here as an example from pixel based engines. I wouldn't // use it, but instead use STM below. // Box2D uses the MKS(meters/kilograms/seconds) unit system. PTM = 1.0 / 30.0 // 1 MKS = 30 GUs // RangerScale is a value you change according to your desires. // The default is 30.0. For example RangerScale = 30.0 // STM is the Scale-to-MKS ratio. // Because Ranger uses transforms we don't think in terms of // pixels but rather in terms of spaces. Ranger's View-space // --without any scaling--is equal to physic-space (aka Box2D-space) // Thus if we want, for example, everything is ranger scaled up // then we need to scale it back down to physic-space and that // is what STM is for. STM = 1.0 / RangerScale // 1 MKS = 30 GUs // VelocityIterations is a resolution adjustment VelocityIterations = 8 // PositionIterations is a resolution adjustment PositionIterations = 3 // DisplayRatio is the aspect ratio. DisplayRatio = 16.0 / 9.0 // Width is the horizontal size Width = 1024.0 + 512.0 // ViewScale is a global scale ViewScale = 0.25 // WindowPositionX is a default position WindowPositionX = 1000.0 // WindowPositionY is a default position WindowPositionY = 100.0 )
const ( // CrossStateNone means has remained in the side since the last check. CrossStateNone = 0 // CrossStateEntered Object has entered zone. CrossStateEntered = 1 // CrossStateExited Object has exit zone. CrossStateExited = 2 // CrossStateInside Object is currently inside CrossStateInside = 3 // CrossStateOutside Object hasn't entered yet CrossStateOutside = 4 // ZoneStateObjectIsOutside object is currently outside of a zone ZoneStateObjectIsOutside = 0 // ZoneStateEnteredOuter Object has entered the outer region ZoneStateEnteredOuter = 1 // ZoneStateEnteredInner Object has entered the inner region ZoneStateEnteredInner = 2 // ZoneStateExitedInner Object has exited the inner region ZoneStateExitedInner = 3 // ZoneStateExitedOuter Object has exited the outer region ZoneStateExitedOuter = 4 // ZoneStateObjectIsInside object is currently inside of a zone ZoneStateObjectIsInside = 5 // ZoneActionNone Object is inside both regions ZoneActionNone = 0 // ZoneActionInward Object is heading inward ZoneActionInward = 1 // ZoneActionOutward Object is heading outward ZoneActionOutward = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IAffineTransform ¶
type IAffineTransform interface { Components() (float64, float64, float64, float64, float64, float64) // ToIdentity sets the transform to an identity matrix ToIdentity() // SetByComp sets by component SetByComp(float64, float64, float64, float64, float64, float64) // SetByTransform sets point using another transform SetByTransform(IAffineTransform) // TransformPoint applys affine transform to point TransformPoint(IPoint) // TransformToPoint applys affine transform to out point, "in" is not modified TransformToPoint(in IPoint, out IPoint) // TransformToComps applys transform and returns results, "in" is not modified TransformToComps(in IPoint) (x, y float64) TransformCompToPoint(x, y float64, out IPoint) // MakeTranslate sets the transform to a Translate matrix MakeTranslate(x, y float64) // MakeTranslateUsingPoint sets the transform to a Translate matrix MakeTranslateUsingPoint(p IPoint) // Translate mutates/concat "this" matrix using tx,ty Translate(tx, ty float64) // MakeScale sets the transform to a Scale matrix MakeScale(x, y float64) // Scale mutates "this" matrix using sx, sy Scale(sx, sy float64) // GetPsuedoScale returns the transform's "a" component, however, // this is only valid if the transform doesn't have a rotation or zoom applied. GetPsuedoScale() float64 // MakeRotate sets the transform to a Rotate matrix MakeRotate(radians float64) // Rotate mutates "this" matrix using radian angle Rotate(radians float64) // Invert (mutates) inverts "this" matrix Invert() // Invert (non-mutating) inverts "this" matrix and sends to "out" InvertTo(out IAffineTransform) // Transpose // Converts either from or to pre or post multiplication. // a c // b d // to // a b // c d Transpose() }
IAffineTransform represents 2D transforms
type IColor ¶
type IColor interface { // SetRed SetRed(r int) // SetGreen SetGreen(r int) // SetBlue SetBlue(r int) // SetAlpha SetAlpha(r int) }
IColor represents Nodes that allow color manipulation.
type IContactListener ¶
type IContactListener interface { HandleBeginContact(nodeA, nodeB INode) bool HandleEndContact(nodeA, nodeB INode) bool }
IContactListener represents a Box2D contact listener
type IDragging ¶
type IDragging interface { IsDragging() bool Delta() IPoint SetMotionState(x, y int32, state uint32) SetButtonState(x, y int32, button uint8, state uint32) SetMotionStateUsing(x, y int32, state uint32, node INode) SetButtonStateUsing(x, y int32, button uint8, state uint32, node INode) }
IDragging represents the node dragging behaviour
type IEngine ¶
type IEngine interface { // Configure constructs a display using SDL and display it. Configure() // Start launches the game loop Start() // Ends shuts down the engine End() // DisplaySize returns the application's window dimensions. DisplaySize() (int, int) // SetClearColor sets the background clear color SetClearColor(color color.RGBA) // PushStart pushes the given node onto the stack as the // first scene to start once the engine's configuration in complete. PushStart(INode) }
IEngine is the main engine API
type IEvent ¶
type IEvent interface { Reset() BeenHandled() bool Handled(mark bool) SetMousePosition(x, y int32) GetMousePosition() (x, y int32) SetMouseRelMovement(x, y int32) GetMouseRelMovement() (x, y int32) SetDirection(uint32) GetDirection() uint32 SetType(uint32) GetType() uint32 SetClicks(uint8) GetClicks() uint8 SetButton(uint8) GetButton() uint8 SetWhich(uint32) GetWhich() uint32 SetState(uint32) GetState() uint32 SetRepeat(uint8) GetRepeat() uint8 SetKeyScan(uint32) GetKeyScan() uint32 SetKeyCode(uint32) GetKeyCode() uint32 SetKeyMotif(uint32) GetKeyMotif() uint32 }
IEvent represents IO event system
type IFilter ¶
type IFilter interface { Build(IWorld) Visit(context IRenderContext, interpolation float64) InheritOnlyRotation() InheritOnlyScale() InheritOnlyTranslation() InheritRotationAndTranslation() InheritAll() }
IFilter represents Transform Filter nodes
type IFilterListener ¶
IFilterListener represents a Box2D filter listener
type IGroup ¶
type IGroup interface { // Children returns the children of current node. // Nodes should override this method for providing any child they contain. Children() []INode AddChild(INode) }
IGroup is a collection of nodes. Group nodes can't be leafs.
type ILine ¶
type ILine interface { Components() (IPoint, IPoint) // SetP1 sets Start end point SetP1(float64, float64) // SetP2 sets End end point SetP2(float64, float64) // SetByComp sets by component SetByComp(x1, y1, x2, y2 float64) // SetByPoint sets point using another point SetByLine(ILine) }
ILine represents 2D lines
type IMesh ¶
type IMesh interface { // Vertices returns the original vertices Vertices() []IPoint // Bucket returns the bucket for transformations Bucket() []IPoint // AddVertex appends the point to vertices AddVertex(x, y float64) SetVertex(x, y float64, index int) // Build Build() }
IMesh represents 2D polygon
type IMotion ¶
type IMotion interface { InitializeMotion() Interpolate(t float64) interface{} SetRate(rate float64) Set(from, to interface{}) SetAutoWrap(bool) SetTimeScale(s float64) Update(dt float64) }
IMotion represents animation behaviors
type INode ¶
type INode interface { ID() int SetID(id int) Name() string // Initialize configures default properties. Initialize(name string) // InitializeWithID configures default properties. InitializeWithID(id int, name string) Build(IWorld) World() IWorld HasParent() bool SetParent(INode) Parent() INode CalcTransform() IAffineTransform Interpolate(interpolation float64) EnterNode(INodeManager) ExitNode(INodeManager) IsVisible() bool SetVisible(bool) IsDirty() bool SetDirty(dirty bool) // RippleDirty passes the dirty flag downward to children. RippleDirty(dirty bool) Handle(IEvent) bool // IScene ITransform // Children IGroup GetBucket() []IPoint Update(msPerUpdate, secPerUpdate float64) }
INode is an abstract object that represents SceneGraph nodes
type INodeList ¶
type INodeList interface { Items() []INode DeleteAt(i int, slice []INode) FindFirstElement(node INode, slice []INode) int Add(node INode) Remove(node INode) }
INodeList is a simple list collection
type INodeManager ¶
type INodeManager interface { ClearEnabled(bool) PreVisit() Visit(interpolation float64) bool PostVisit() Update(msPerUpdate, secPerUpdate float64) PushNode(INode) PopNode() INode ReplaceNode(INode) RouteEvents(IEvent) RegisterTarget(target INode) UnRegisterTarget(target INode) RegisterEventTarget(target INode) UnRegisterEventTarget(target INode) End() Debug() }
INodeManager manages node on a stack and forms a SceneGraph
type IPalette ¶
type IPalette interface { // Components return each component Components() (r, g, b, a uint8) // AsUInt64 as 64nit unsigned AsUInt64() uint64 // Color as image.RGBA Color() color.RGBA // R is red component R() uint8 // G is green component G() uint8 // B is blus component B() uint8 // A is alpha component A() uint8 // SetRed SetRed(r int) // SetGreen SetGreen(r int) // SetBlue SetBlue(r int) // SetAlpha SetAlpha(r int) }
IPalette represents colors
type IParticle ¶
type IParticle interface { Update(dt float64) IsActive() bool Activate(bool) Reset() SetPosition(x, y float64) GetPosition() IPoint SetLifespan(duration float64) SetVelocity(direction, speed float64) Visual() INode }
IParticle represents a particle
type IParticleActivator ¶
type IParticleActivator interface { Activate(particle IParticle, center IPoint) SetMaxLifetime(duration float64) SetMaxSpeed(speed float64) }
IParticleActivator activates particles
type IParticleSystem ¶
type IParticleSystem interface { AddParticle(particle IParticle) Update(dt float64) SetPosition(x, y float64) SetAutoTrigger(bool) Activate(bool) TriggerOneshot() TriggerAt(pos IPoint) TriggerExplosion() }
IParticleSystem represents a particle system
type IPoint ¶
type IPoint interface { // Components returns the x,y parts Components() (float64, float64) // ComponentsAsInt32 return x,y parts for render context ComponentsAsInt32() (int32, int32) // X sets the x component X() float64 // Y sets the y component Y() float64 // SetByComp sets by component SetByComp(x, y float64) // SetByPoint sets point using another point SetByPoint(IPoint) }
IPoint represents 2D points
type IPolygon ¶
type IPolygon interface { // AddVertex appends the point to vertices AddVertex(x, y float64) SetVertex(x, y float64, index int) // Mesh returns the underlying mesh Mesh() IMesh // Build Build() PointInside(p IPoint) bool }
IPolygon represents 2D lines
type IRasterFont ¶
type IRasterFont interface { Initialize(dataFile string, relativePath string) // Glyph returns an array of vertices that matches the character Glyph(char byte) []uint8 GlyphWidth() int }
IRasterFont is the bitmap raster font defined in assets/raster_font.data
type IRectangle ¶
type IRectangle interface { // Dimesions returns width, height Dimesions() (float64, float64) // DimesionsAsInt32 returns width, height used for render context DimesionsAsInt32() (int32, int32) // Min returns the upper left corner Min() IPoint // Max returns the lower right corner Max() IPoint // Set sets corners i.e. the dimensions Set(minx, miny, maxx, maxy float64) // SetBounds set the min/max based on vertex array SetBounds(vertices []IPoint) // Expand expands the rectangle if needed based on array. Expand(vertices []IPoint) // Intersets indicates if "this" rectangle intersects "rect" IntersectsOther(rect IRectangle) bool // ContainsPoint determines if point is within "this" rectangle ContainsPoint(p IPoint) bool }
IRectangle represents 2D points
type IRender ¶
type IRender interface {
Draw(context IRenderContext)
}
IRender is the visual interface for drawing
type IRenderContext ¶
type IRenderContext interface { // Initialize render context Initialize() // Apply transform to current context transform Apply(IAffineTransform) // Pre draw Pre() // Save pushes the current state onto the stack Save() // Restore pops the current state Restore() // Post Post() // TransformPoint transforms an IPoint using the current context. TransformPoint(p, out IPoint) // TransformPoints transforms a line/rectangle-corners using the current context. TransformPoints(p1, p2, out1, out2 IPoint) // TransformArray transforms a array of vertices using the current context // into output bucket. TransformArray(vertices, bucket []IPoint) TransformMesh(mesh IMesh) TransformPolygon(poly IPolygon) // ,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--.,--. // Draw functions render directly to the device. // ,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__.,__. SetDrawColor(color IPalette) DrawPoint(x, y int32) DrawBigPoint(x, y int32) DrawLine(x1, y1, x2, y2 int32) DrawLineUsing(p1, p2 IPoint) DrawRectangle(rect IRectangle) DrawFilledRectangle(rect IRectangle) DrawCheckerBoard(size int) DrawText(x, y float64, text string, scale int, fill int, invert bool) RenderLine(x1, y1, x2, y2 float64) RenderLines(mesh IMesh) RenderPolygon(poly IPolygon, style int) // Render an axis aligned rectangle. Rotating any of the vertices // will cause strange rendering behaviours RenderAARectangle(min, max IPoint, fill int) RenderCheckerBoard(mesh IMesh, oddColor IPalette, evenColor IPalette) }
IRenderContext represents visual rendering context
type ITransform ¶
type ITransform interface { CalcFilteredTransform( excludeTranslation bool, excludeRotation bool, excludeScale bool, aft IAffineTransform) // AffineTransform returns this node's transform AffineTransform() IAffineTransform InverseTransform() IAffineTransform SetPosition(x, y float64) Position() IPoint SetRotation(radian float64) Rotation() float64 SetScale(scale float64) Scale() float64 }
ITransform represents the transform properties of an INode
type ITransition ¶
type ITransition interface { Reset() SetPauseTime(milliseconds float64) Inc(dt float64) UpdateTransition(dt float64) ReadyToTransition() bool }
ITransition scene timing and transitions
type ITween ¶
type ITween interface { Update(dt float64) (value float64, isFinished bool) Elapsed() float64 Reset() }
ITween represent tween behaviours
type ITweenEquation ¶
ITweenEquation represents tween equation
type IVector ¶
type IVector interface { Components() (float64, float64) // X sets the x component X() float64 // Y sets the y component Y() float64 // SetByComp sets by component SetByComp(x, y float64) // SetByPoint sets point using another point SetByPoint(IPoint) // SetByVector sets point using another vector SetByVector(IVector) SetByAngle(radians float64) // Length returns the square root length Length() float64 // LengthSqr return the squared length LengthSqr() float64 // Scale vector by s Scale(s float64) // Add offsets a this vector Add(x, y float64) // Sub offsets a this vector Sub(x, y float64) AddV(IVector) SubV(IVector) // Div vector by d Div(d float64) // AngleX computes the angle (radians) between this vector and v. AngleX(v IVector) float64 // Normalize normalizes this vector, if the vector is zero // then nothing happens Normalize() // SetDirection set the direction of the vector, however, // it will erase the magnitude SetDirection(radians float64) // CrossCW computes the cross-product faster in the CW direction CrossCW() // CrossCCW computes the cross-product faster in the CCW direction CrossCCW() }
IVector represents 2D vectors that have direction and magnitude
type IVectorFont ¶
type IVectorFont interface { Initialize(dataFile string, relativePath string) HorizontalOffset() float64 VerticalOffset() float64 Scale() float64 // Glyph returns an array of vertices that matches the character Glyph(char byte) []float64 }
IVectorFont is the polygon font defined in assets/vector_font.data
type IVelocity ¶
type IVelocity interface { // SetMin sets minimum magnitude SetMin(float64) // SetMax sets maximum magnitude SetMax(float64) // SetMinMax sets min/maximum magnitude SetMinMax(float64, float64) // SetMagnitude set the current magnitude directly SetMagnitude(float64) // Magnitude returns the current magnitude Magnitude() float64 // Range returns the min/max magnitude range Range() (float64, float64) // SetDirection set the direction vector component SetDirectionByVector(IVector) SetDirectionByAngle(radians float64) // Direction returns the current direction component Direction() IVector // ConstrainMagnitude enables/disables the limiting of magnitude // to within the min/max range ConstrainMagnitude(bool) ApplyToPoint(point IPoint) }
IVelocity represents the direction and magnitude of a vector Velocity's direction is alway defined relative to the +X axis. Default direction is +X axis.
type IWorld ¶
type IWorld interface { SetRenderer(*sdl.Renderer) Renderer() *sdl.Renderer Context() IRenderContext // WindowSize is the device window dimensions. WindowSize() IPoint ViewSize() IPoint // Title is the window title Title() string // SetViewSpace configures the view-space matrix SetViewSpace() // ViewSpace returns the view-space matrix ViewSpace() IAffineTransform InvViewSpace() IAffineTransform VectorFont() IVectorFont RasterFont() IRasterFont WorkingPath() string }
IWorld represents app window properties
type IZoneListener ¶
type IZoneListener interface {
Notify(state, id int)
}
IZoneListener is for objects wanting to be notified of Zone events
type IZoomTransform ¶
type IZoomTransform interface { // GetTransform updates and returns the internal transform. GetTransform() IAffineTransform // Update modifies the internal transform state based on current values. Update() // SetPosition is an absolute position. Typically you would use TranslateBy. SetPosition(x, y float64) // Scale returns the current scale factor Scale() float64 PsuedoScale() float64 // SetScale sets the scale based on the current scale value making // this a relative scale. SetScale(scale float64) // SetAt sets the center zoom point. SetAt(x, y float64) // ZoomBy performs a relative zoom based on the current scale/zoom. ZoomBy(dx, dy float64) // TranslateBy is a relative positional translation. TranslateBy(dx, dy float64) }
IZoomTransform represents 2D zoom transform
Source Files ¶
- Ifilter.go
- iaffinetransform.go
- icolor.go
- icontact_listener.go
- idragging.go
- iengine.go
- ievent.go
- ifilter_listener.go
- igroup.go
- iline.go
- imesh.go
- imotion.go
- inode.go
- inode_list.go
- inode_manager.go
- ipalette.go
- iparticle.go
- iparticle_activator.go
- iparticle_system.go
- ipoint.go
- ipolygon.go
- iraster_font.go
- irectangle.go
- irender.go
- irender_context.go
- iscene.go
- itransform.go
- itransitioning.go
- itween.go
- ivector.go
- ivector_font.go
- ivelocity.go
- iworld.go
- izone.go
- izone_listener.go
- izoom_transform.go