Documentation ¶
Index ¶
- Variables
- func Clamp(a, b, c float32) float32
- func Exit()
- func Height() float32
- func IsIntersecting(rect1 AABB, rect2 AABB) bool
- func LoadShader(vertSrc, fragSrc string) *webgl.Program
- func Open(title string, width, height int, fullscreen bool, r Responder)
- func SetBg(color uint32)
- func SetCamera(c *Camera)
- func SetFPSLimit(limit int) error
- func Width() float32
- type AABB
- type Action
- type AnimationComponent
- type AnimationSystem
- type Assets
- type Batch
- type ByFirstgid
- type Camera
- type Clock
- type CollisionComponent
- type CollisionMasterComponent
- type CollisionMessage
- type CollisionSystem
- type Color
- type Component
- type Drawable
- type Entity
- type Font
- type Game
- func (g *Game) Close()
- func (g *Game) Key(key Key, modifier Modifier, action Action)
- func (g *Game) Mouse(x, y float32, action Action)
- func (g *Game) Preload()
- func (g *Game) Render()
- func (g *Game) Resize(w, h int)
- func (g *Game) Scroll(amount float32)
- func (g *Game) Setup()
- func (g *Game) Type(char rune)
- func (g *Game) Update(dt float32)
- type Handler
- type Image
- type ImageObject
- type Key
- type KeyManager
- type KeyState
- type Level
- type Line
- type LinkComponent
- type Loader
- type Message
- type MessageManager
- type Modifier
- type Point
- func (p *Point) Add(p2 Point)
- func (p *Point) AddScalar(s float32)
- func (p *Point) Multiply(p2 Point)
- func (p *Point) MultiplyScalar(s float32)
- func (a *Point) Normalize() (Point, float32)
- func (p *Point) PointDistance(p2 Point) float32
- func (p *Point) PointDistanceSquared(p2 Point) float32
- func (a *Point) ProjectOnto(b Point) Point
- func (p *Point) Set(x, y float32)
- func (p *Point) SetTo(v float32)
- func (p *Point) Subtract(p2 Point)
- func (p *Point) SubtractScalar(s float32)
- type PriorityLevel
- type Region
- type RenderComponent
- type RenderSystem
- type Renderable
- type Resource
- type Responder
- type SpaceComponent
- type Sprite
- type Spritesheet
- type System
- type Systemer
- type TMXImgLayer
- type TMXImgSrc
- type TMXLayer
- type TMXLevel
- type TMXObj
- type TMXObjGroup
- type TMXPolyline
- type TMXTileset
- type TMXTilesetSrc
- type Texture
- type World
Constants ¶
This section is empty.
Variables ¶
var ( Time *Clock Files *Loader Mailbox MessageManager Gl = gl Cam *Camera Wo Responder WorldBounds AABB )
var ( Arrow *glfw.Cursor IBeam *glfw.Cursor Crosshair *glfw.Cursor Hand *glfw.Cursor HResize *glfw.Cursor VResize *glfw.Cursor )
var ( MOVE = Action(0) PRESS = Action(1) RELEASE = Action(2) SHIFT = Modifier(0x0001) CONTROL = Modifier(0x0002) ALT = Modifier(0x0004) SUPER = Modifier(0x0008) )
var ( Dash = Key(189) Apostrophe = Key(222) Semicolon = Key(186) Equals = Key(187) Comma = Key(188) Period = Key(190) Slash = Key(191) Backslash = Key(220) Backspace = Key(8) Tab = Key(9) CapsLock = Key(20) Space = Key(32) Enter = Key(13) Escape = Key(27) Insert = Key(45) PrintScreen = Key(42) Delete = Key(46) PageUp = Key(33) PageDown = Key(34) Home = Key(36) End = Key(35) Pause = Key(19) ScrollLock = Key(145) ArrowLeft = Key(37) ArrowRight = Key(39) ArrowDown = Key(40) ArrowUp = Key(38) LeftBracket = Key(219) LeftShift = Key(16) LeftControl = Key(17) LeftSuper = Key(73) LeftAlt = Key(18) RightBracket = Key(221) RightShift = Key(16) RightControl = Key(17) RightSuper = Key(73) RightAlt = Key(18) Zero = Key(48) One = Key(49) Two = Key(50) Three = Key(51) Four = Key(52) Five = Key(53) Six = Key(54) Seven = Key(55) Eight = Key(56) Nine = Key(57) F1 = Key(112) F2 = Key(113) F3 = Key(114) F4 = Key(115) F5 = Key(116) F6 = Key(117) F7 = Key(118) F8 = Key(119) F9 = Key(120) F10 = Key(121) F11 = Key(122) F12 = Key(123) A = Key(65) B = Key(66) C = Key(67) D = Key(68) E = Key(69) F = Key(70) G = Key(71) H = Key(72) I = Key(73) J = Key(74) K = Key(75) L = Key(76) M = Key(77) N = Key(78) O = Key(79) P = Key(80) Q = Key(81) R = Key(82) S = Key(83) T = Key(84) U = Key(85) V = Key(86) W = Key(87) X = Key(88) Y = Key(89) Z = Key(90) NumLock = Key(144) NumMultiply = Key(106) NumDivide = Key(111) NumAdd = Key(107) NumSubtract = Key(109) NumZero = Key(96) NumOne = Key(97) NumTwo = Key(98) NumThree = Key(99) NumFour = Key(100) NumFive = Key(101) NumSix = Key(102) NumSeven = Key(103) NumEight = Key(104) NumNine = Key(105) NumDecimal = Key(110) NumEnter = Key(13) )
var ( KEY_STATE_UP string = "up" KEY_STATE_DOWN string = "down" KEY_STATE_JUST_DOWN string = "justdown" KEY_STATE_JUST_UP string = "justup" Keys KeyManager )
Functions ¶
func IsIntersecting ¶
func LoadShader ¶
func SetFPSLimit ¶
Types ¶
type AnimationComponent ¶
type AnimationComponent struct { Index int // What frame in the is being used Rate float32 // How often frames should increment, in seconds. S *Spritesheet // Pointer to the source spritesheet Animations map[string][]int // All possible animations CurrentAnimation []int // The currently animation // contains filtered or unexported fields }
Component that controls animation in rendering entities
func NewAnimationComponent ¶
func NewAnimationComponent() *AnimationComponent
Create a new pointer to AnimationComponent
func (*AnimationComponent) AddAnimation ¶
func (ac *AnimationComponent) AddAnimation(name string, indexes []int)
func (*AnimationComponent) Cell ¶
func (ac *AnimationComponent) Cell() *Region
Bug(me) Don't need to use _index at all, use ac.CurrentAnimation[ac.Index] instead. Set ac.Index as a private member variable
func (*AnimationComponent) Increment ¶
func (ac *AnimationComponent) Increment()
Increment the frame
func (AnimationComponent) Name ¶
func (ac AnimationComponent) Name() string
func (*AnimationComponent) SelectAnimation ¶
func (ac *AnimationComponent) SelectAnimation(name string)
type AnimationSystem ¶
type AnimationSystem struct {
*System
}
func (AnimationSystem) Name ¶
func (a AnimationSystem) Name() string
func (*AnimationSystem) New ¶
func (a *AnimationSystem) New()
func (*AnimationSystem) Update ¶
func (a *AnimationSystem) Update(e *Entity, dt float32)
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
func (*Batch) SetProjection ¶
type ByFirstgid ¶
type ByFirstgid []TMXTileset
func (ByFirstgid) Len ¶
func (t ByFirstgid) Len() int
func (ByFirstgid) Less ¶
func (t ByFirstgid) Less(i, j int) bool
func (ByFirstgid) Swap ¶
func (t ByFirstgid) Swap(i, j int)
type Camera ¶
type Camera struct { DeadzoneSize Point // contains filtered or unexported fields }
A rather basic camera
func (*Camera) FollowEntity ¶
type CollisionComponent ¶
func (CollisionComponent) Name ¶
func (cc CollisionComponent) Name() string
type CollisionMasterComponent ¶
type CollisionMasterComponent struct { }
func (CollisionMasterComponent) Is ¶
func (cm CollisionMasterComponent) Is() bool
func (CollisionMasterComponent) Name ¶
func (cm CollisionMasterComponent) Name() string
type CollisionMessage ¶
func (CollisionMessage) Type ¶
func (collision CollisionMessage) Type() string
type CollisionSystem ¶
type CollisionSystem struct {
*System
}
func (CollisionSystem) Name ¶
func (cs CollisionSystem) Name() string
func (*CollisionSystem) New ¶
func (cs *CollisionSystem) New()
func (*CollisionSystem) Update ¶
func (cs *CollisionSystem) Update(entity *Entity, dt float32)
type Entity ¶
func (*Entity) AddComponent ¶
func (*Entity) DoesRequire ¶
func (*Entity) GetComponent ¶
GetComponent takes a double pointer to a Component, and populates it with the value of the right type.
type Font ¶
type Font struct { URL string Size float64 BG Color FG Color // contains filtered or unexported fields }
TODO FG and BG color config
type ImageObject ¶
type ImageObject struct {
// contains filtered or unexported fields
}
func NewImageObject ¶
func NewImageObject(img *image.NRGBA) *ImageObject
func (*ImageObject) Data ¶
func (i *ImageObject) Data() interface{}
func (*ImageObject) Height ¶
func (i *ImageObject) Height() int
func (*ImageObject) Width ¶
func (i *ImageObject) Width() int
type KeyManager ¶
type KeyState ¶
type KeyState struct {
// contains filtered or unexported fields
}
func (KeyState) JustPressed ¶
func (KeyState) JustReleased ¶
type Level ¶
type Level struct { Width int Height int TileWidth int TileHeight int Tiles []*tile LineBounds []Line Images []*tile }
func (*Level) Render ¶
func (lvl *Level) Render(b *Batch, render *RenderComponent, space *SpaceComponent)
type Line ¶
func (*Line) LineIntersection ¶
Returns the point where the two lines intersect
func (*Line) PointDistance ¶
Returns the squared euclidean distance from a point to a line *segment*
func (*Line) PointDistanceSquared ¶
Returns the squared euclidean distance from a point to a line *segment*
type LinkComponent ¶
type LinkComponent struct {
Entity *Entity
}
func (LinkComponent) Name ¶
func (lc LinkComponent) Name() string
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
func (*Loader) AddFromDir ¶
type MessageManager ¶
type MessageManager struct {
// contains filtered or unexported fields
}
func (*MessageManager) Dispatch ¶
func (mm *MessageManager) Dispatch(name string, message interface{})
func (*MessageManager) Listen ¶
func (mm *MessageManager) Listen(messageType string, handler Handler)
type Point ¶
type Point struct {
X, Y float32
}
func MinimumTranslation ¶
func (*Point) MultiplyScalar ¶
func (*Point) PointDistance ¶
func (*Point) PointDistanceSquared ¶
func (*Point) ProjectOnto ¶
Returns the vector produced by projecting a on to b
func (*Point) SubtractScalar ¶
type PriorityLevel ¶
type PriorityLevel int
const ( HUDGround PriorityLevel = 4 Foreground PriorityLevel = 3 MiddleGround PriorityLevel = 2 ScenicGround PriorityLevel = 1 Background PriorityLevel = 0 )
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
func (*Region) Render ¶
func (r *Region) Render(b *Batch, render *RenderComponent, space *SpaceComponent)
type RenderComponent ¶
type RenderComponent struct { Display Renderable Scale Point Label string Priority PriorityLevel Transparency float32 Color uint32 }
func NewRenderComponent ¶
func NewRenderComponent(display Renderable, scale Point, label string) RenderComponent
func (RenderComponent) Name ¶
func (rc RenderComponent) Name() string
type RenderSystem ¶
type RenderSystem struct { *System // contains filtered or unexported fields }
func (*RenderSystem) AddEntity ¶
func (rs *RenderSystem) AddEntity(e *Entity)
func (RenderSystem) Name ¶
func (rs RenderSystem) Name() string
func (*RenderSystem) New ¶
func (rs *RenderSystem) New()
func (*RenderSystem) Post ¶
func (rs *RenderSystem) Post()
func (RenderSystem) Pre ¶
func (rs RenderSystem) Pre()
func (RenderSystem) Priority ¶
func (rs RenderSystem) Priority() int
func (*RenderSystem) Update ¶
func (rs *RenderSystem) Update(entity *Entity, dt float32)
type Renderable ¶
type Renderable interface {
Render(b *Batch, render *RenderComponent, space *SpaceComponent)
}
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func NewResource ¶
type SpaceComponent ¶
func (SpaceComponent) AABB ¶
func (sc SpaceComponent) AABB() AABB
func (SpaceComponent) Name ¶
func (sc SpaceComponent) Name() string
type Sprite ¶
type Spritesheet ¶
type Spritesheet struct {
CellWidth, CellHeight int // The dimensions of the cells
// contains filtered or unexported fields
}
Spritesheet is a class that stores a set of tiles from a file, used by tilemaps and animations
func NewSpritesheet ¶
func NewSpritesheet(textureName string, cellWidth, cellHeight int) *Spritesheet
Simple handler for creating a new spritesheet from a file textureName is the name of a texture already preloaded with engi.Files.Add
func (*Spritesheet) Cell ¶
func (s *Spritesheet) Cell(i int) *Region
Get the region at the index i, updates and pulls from cache if need be
func (Spritesheet) Height ¶
func (s Spritesheet) Height() float32
The amount of tiles on the y-axis of the spritesheet
func (Spritesheet) Width ¶
func (s Spritesheet) Width() float32
The amount of tiles on the x-axis of the spritesheet
type TMXImgLayer ¶
type TMXLevel ¶
type TMXLevel struct { Width int `xml:"width,attr"` Height int `xml:"height,attr"` TileWidth int `xml:"tilewidth,attr"` TileHeight int `xml:"tileheight,attr"` Tilesets []TMXTileset `xml:"tileset"` Layers []TMXLayer `xml:"layer"` ObjGroups []TMXObjGroup `xml:"objectgroup"` ImgLayers []TMXImgLayer `xml:"imagelayer"` }
type TMXObj ¶
type TMXObj struct { X float64 `xml:"x,attr"` Y float64 `xml:"y,attr"` Polylines []TMXPolyline `xml:"polyline"` }
type TMXObjGroup ¶
type TMXPolyline ¶
type TMXPolyline struct {
Points string `xml:"points,attr"`
}
type TMXTileset ¶
type TMXTilesetSrc ¶
type TMXTilesetSrc struct { Source string `xml:"source,attr"` Width int `xml:"width,attr"` Height int `xml:"height,attr"` }
Just used to create levelTileset->Image
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
func NewTexture ¶
func (*Texture) Render ¶
func (t *Texture) Render(b *Batch, render *RenderComponent, space *SpaceComponent)