Documentation ¶
Overview ¶
Package common contains the most-common System implementations according to the `engo.io/ecs` definition, to be used in conjunction with `engo.io/engo`.
Index ¶
- Constants
- Variables
- func AudioSystemPreload()
- func ImageToNRGBA(img image.Image, width, height int) *image.NRGBA
- func IsIntersecting(rect1 engo.AABB, rect2 engo.AABB) bool
- func LoadShader(vertSrc, fragSrc string) (*gl.Program, error)
- func MinimumTranslation(rect1 engo.AABB, rect2 engo.AABB) engo.Point
- func SetBackground(c color.Color)
- func UploadTexture(img Image) *gl.Texture
- type Animation
- type AnimationComponent
- func (ac *AnimationComponent) AddAnimation(action *Animation)
- func (ac *AnimationComponent) AddAnimations(actions []*Animation)
- func (ac *AnimationComponent) AddDefaultAnimation(action *Animation)
- func (ac *AnimationComponent) Cell() Drawable
- func (ac *AnimationComponent) NextFrame()
- func (ac *AnimationComponent) SelectAnimationByAction(action *Animation)
- func (ac *AnimationComponent) SelectAnimationByName(name string)
- type AnimationSystem
- type AudioComponent
- type AudioResource
- type AudioSystem
- type BasicSpritesheet
- func (s *BasicSpritesheet) Cell(index int) Texture
- func (s *BasicSpritesheet) CellCount() int
- func (s *BasicSpritesheet) Cells() []Texture
- func (s *BasicSpritesheet) Drawable(index int) Drawable
- func (s *BasicSpritesheet) Drawables() []Drawable
- func (s BasicSpritesheet) Height() float32
- func (s BasicSpritesheet) Width() float32
- type ByFirstgid
- type CameraAxis
- type CameraMessage
- type CameraSystem
- func (cam *CameraSystem) Angle() float32
- func (cam *CameraSystem) FollowEntity(basic *ecs.BasicEntity, space *SpaceComponent)
- func (cam *CameraSystem) New(*ecs.World)
- func (cam *CameraSystem) Remove(ecs.BasicEntity)
- func (cam *CameraSystem) Update(dt float32)
- func (cam *CameraSystem) X() float32
- func (cam *CameraSystem) Y() float32
- func (cam *CameraSystem) Z() float32
- type Circle
- type CollisionComponent
- type CollisionMessage
- type CollisionSystem
- type ComplexTriangles
- type Cursor
- type Drawable
- type EdgeScroller
- type EntityScroller
- type Font
- type FontAtlas
- type FontResource
- type Format
- type FragmentShaderCompilationError
- type Image
- type ImageLayer
- type ImageObject
- type KeyboardScroller
- type Level
- type Mouse
- type MouseComponent
- type MouseRotator
- type MouseSystem
- type MouseZoomer
- type Object
- type ObjectLayer
- type Player
- func (p *Player) Close() error
- func (p *Player) Current() time.Duration
- func (p *Player) Pause() error
- func (p *Player) Play(background bool) error
- func (p *Player) Seek(background bool, offset time.Duration) error
- func (p *Player) SetVolume(vol float64)
- func (p *Player) State() State
- func (p *Player) Stop() error
- func (p *Player) Total(background bool) time.Duration
- func (p *Player) Volume() float64
- type PolylineObject
- type ReadSeekCloser
- type Rectangle
- type RenderComponent
- type RenderSystem
- type Shader
- type SpaceComponent
- type Spritesheet
- type State
- type TMXImageLayer
- type TMXImageSrc
- type TMXLevel
- type TMXObject
- type TMXObjectLayer
- type TMXPolyline
- type TMXResource
- type TMXTileLayer
- type TMXTileset
- type TMXTilesetSrc
- type Text
- type TextResource
- type Texture
- type TextureRepeating
- type TextureResource
- type TileLayer
- type Triangle
- type TriangleType
- type VertexShaderCompilationError
Constants ¶
const ( MouseRotatorPriority = 100 MouseZoomerPriority = 110 EdgeScrollerPriority = 120 KeyboardScrollerPriority = 130 EntityScrollerPriority = 140 )
const ( CursorNone = iota CursorArrow CursorCrosshair CursorHand CursorIBeam CursorHResize CursorVResize )
const MouseSystemPriority = 100
const (
RenderSystemPriority = -1000
)
Variables ¶
var ( MinZoom float32 = 0.25 MaxZoom float32 = 3 CameraBounds engo.AABB )
var ( DefaultShader = &basicShader{cameraEnabled: true} HUDShader = &basicShader{cameraEnabled: false} LegacyShader = &legacyShader{cameraEnabled: true} LegacyHUDShader = &legacyShader{cameraEnabled: false} TextShader = &textShader{cameraEnabled: true} TextHUDShader = &textShader{cameraEnabled: false} )
var MasterVolume float64 = 1
var UnicodeCap = 200
UnicodeCap is the amount of unicode characters the fonts will be able to use, starting from index 0.
Functions ¶
func AudioSystemPreload ¶
func AudioSystemPreload()
AudioSystemPreload has to be called before preloading any `.wav` files
func ImageToNRGBA ¶
ImageToNRGBA takes a given `image.Image` and converts it into an `image.NRGBA`. Especially useful when transforming image.Uniform to something usable by `engo`.
func LoadShader ¶
LoadShader takes a Vertex-shader and Fragment-shader, compiles them and attaches them to a newly created glProgram. It will log possible compilation errors
func SetBackground ¶
func UploadTexture ¶
UploadTexture sends the image to the GPU, to be kept in GPU RAM
Types ¶
type AnimationComponent ¶
type AnimationComponent struct { Drawables []Drawable // Renderables Animations map[string]*Animation // All possible animations CurrentAnimation *Animation // The current animation Rate float32 // How often frames should increment, in seconds. // contains filtered or unexported fields }
AnimationComponent tracks animations of an entity it is part of. This component should be created using NewAnimationComponent.
func NewAnimationComponent ¶
func NewAnimationComponent(drawables []Drawable, rate float32) AnimationComponent
NewAnimationComponent creates an AnimationComponent containing all given drawables. Animations will be played using the given rate.
func (*AnimationComponent) AddAnimation ¶
func (ac *AnimationComponent) AddAnimation(action *Animation)
AddAnimation registers an animation under its name, making it available through SelectAnimationByName.
func (*AnimationComponent) AddAnimations ¶
func (ac *AnimationComponent) AddAnimations(actions []*Animation)
AddAnimations registers all given animations.
func (*AnimationComponent) AddDefaultAnimation ¶
func (ac *AnimationComponent) AddDefaultAnimation(action *Animation)
AddDefaultAnimation adds an animation which is used when no other animation is playing.
func (*AnimationComponent) Cell ¶
func (ac *AnimationComponent) Cell() Drawable
Cell returns the drawable for the current frame.
func (*AnimationComponent) NextFrame ¶
func (ac *AnimationComponent) NextFrame()
NextFrame advances the current animation by one frame.
func (*AnimationComponent) SelectAnimationByAction ¶
func (ac *AnimationComponent) SelectAnimationByAction(action *Animation)
SelectAnimationByAction sets the current animation. An nil action value selects the default animation.
func (*AnimationComponent) SelectAnimationByName ¶
func (ac *AnimationComponent) SelectAnimationByName(name string)
SelectAnimationByName sets the current animation. The name must be registered.
type AnimationSystem ¶
type AnimationSystem struct {
// contains filtered or unexported fields
}
AnimationSystem tracks AnimationComponents, advancing their current animation.
func (*AnimationSystem) Add ¶
func (a *AnimationSystem) Add(basic *ecs.BasicEntity, anim *AnimationComponent, render *RenderComponent)
Add starts tracking the given entity.
func (*AnimationSystem) Remove ¶
func (a *AnimationSystem) Remove(basic ecs.BasicEntity)
Remove stops tracking the given entity.
func (*AnimationSystem) Update ¶
func (a *AnimationSystem) Update(dt float32)
Update advances the animations of all tracked entities.
type AudioComponent ¶
type AudioComponent struct { File string Repeat bool Background bool RawVolume float64 // contains filtered or unexported fields }
AudioComponent is a Component which is used by the AudioSystem
func (*AudioComponent) SetVolume ¶
func (ac *AudioComponent) SetVolume(volume float64)
type AudioResource ¶
type AudioResource struct { Player *Player // contains filtered or unexported fields }
AudioResource is a wrapper for `*Player` which is being passed by the the `engo.Files.Resource` method in the case of `.wav` files.
func (AudioResource) URL ¶
func (f AudioResource) URL() string
type AudioSystem ¶
type AudioSystem struct { HeightModifier float32 // contains filtered or unexported fields }
AudioSystem is a System that allows for sound effects and / or music
func (*AudioSystem) Add ¶
func (a *AudioSystem) Add(basic *ecs.BasicEntity, audio *AudioComponent, space *SpaceComponent)
Add adds a new entity to the AudioSystem. AudioComponent is always required, and the SpaceComponent is required as soon as AudioComponent.Background is false. (So if it's not a background noise, we want to know where it's originated from)
func (*AudioSystem) New ¶
func (a *AudioSystem) New(w *ecs.World)
func (*AudioSystem) Remove ¶
func (a *AudioSystem) Remove(basic ecs.BasicEntity)
func (*AudioSystem) Update ¶
func (a *AudioSystem) Update(dt float32)
type BasicSpritesheet ¶
type BasicSpritesheet struct {
// contains filtered or unexported fields
}
Spritesheet is a class that stores a set of tiles from a file, used by tilemaps and animations
func NewBasicSpritesheetFromFile ¶
func NewBasicSpritesheetFromFile(textureName string, cellWidth, cellHeight int) *BasicSpritesheet
NewBasicSpritesheetFromFile is a simple handler for creating a new spritesheet from a file textureName is the name of a texture already preloaded with engo.Files.Add
func NewBasicSpritesheetFromTexture ¶
func NewBasicSpritesheetFromTexture(tr *TextureResource, cellWidth, cellHeight int) *BasicSpritesheet
func (*BasicSpritesheet) Cell ¶
func (s *BasicSpritesheet) Cell(index int) Texture
Cell gets the region at the index i, updates and pulls from cache if need be
func (*BasicSpritesheet) CellCount ¶
func (s *BasicSpritesheet) CellCount() int
func (*BasicSpritesheet) Cells ¶
func (s *BasicSpritesheet) Cells() []Texture
func (*BasicSpritesheet) Drawable ¶
func (s *BasicSpritesheet) Drawable(index int) Drawable
func (*BasicSpritesheet) Drawables ¶
func (s *BasicSpritesheet) Drawables() []Drawable
func (BasicSpritesheet) Height ¶
func (s BasicSpritesheet) Height() float32
Height is the amount of tiles on the y-axis of the spritesheet
func (BasicSpritesheet) Width ¶
func (s BasicSpritesheet) Width() float32
Width is the amount of tiles on the x-axis of the spritesheet
type ByFirstgid ¶
type ByFirstgid []TMXTileset
func (ByFirstgid) Less ¶
func (t ByFirstgid) Less(i, j int) bool
Less returns if t's i Firstgid is less than t's j
type CameraAxis ¶
type CameraAxis uint8
CameraAxis is the axis at which the Camera can/has to move
const ( XAxis CameraAxis = iota YAxis ZAxis Angle )
type CameraMessage ¶
type CameraMessage struct { Axis CameraAxis Value float32 Incremental bool Duration time.Duration // contains filtered or unexported fields }
CameraMessage is a message that can be sent to the Camera (and other Systemers), to indicate movement
func (CameraMessage) Type ¶
func (CameraMessage) Type() string
type CameraSystem ¶
type CameraSystem struct {
// contains filtered or unexported fields
}
CameraSystem is a System that manages the state of the virtual camera
func (*CameraSystem) Angle ¶
func (cam *CameraSystem) Angle() float32
Angle returns the angle (in degrees) at which the Camera is rotated
func (*CameraSystem) FollowEntity ¶
func (cam *CameraSystem) FollowEntity(basic *ecs.BasicEntity, space *SpaceComponent)
func (*CameraSystem) New ¶
func (cam *CameraSystem) New(*ecs.World)
func (*CameraSystem) Remove ¶
func (cam *CameraSystem) Remove(ecs.BasicEntity)
func (*CameraSystem) Update ¶
func (cam *CameraSystem) Update(dt float32)
func (*CameraSystem) X ¶
func (cam *CameraSystem) X() float32
X returns the X-coordinate of the location of the Camera
func (*CameraSystem) Y ¶
func (cam *CameraSystem) Y() float32
Y returns the Y-coordinate of the location of the Camera
func (*CameraSystem) Z ¶
func (cam *CameraSystem) Z() float32
Z returns the Z-coordinate of the location of the Camera
type Circle ¶
Circle is a basic circular form; the dimensions / radius are controlled via the `SpaceComponent`. This was made possible by the shared knowledge of Olivier Gagnon (@hydroflame).
type CollisionComponent ¶
type CollisionMessage ¶
type CollisionMessage struct { Entity collisionEntity To collisionEntity }
func (CollisionMessage) Type ¶
func (CollisionMessage) Type() string
type CollisionSystem ¶
type CollisionSystem struct {
// contains filtered or unexported fields
}
func (*CollisionSystem) Add ¶
func (c *CollisionSystem) Add(basic *ecs.BasicEntity, collision *CollisionComponent, space *SpaceComponent)
func (*CollisionSystem) Remove ¶
func (c *CollisionSystem) Remove(basic ecs.BasicEntity)
func (*CollisionSystem) Update ¶
func (cs *CollisionSystem) Update(dt float32)
type ComplexTriangles ¶
type ComplexTriangles struct { // Points are the points the form is made of. They should be defined on a scale from 0 to 1, where (0, 0) starts // at the top-left of the area (as defined by the `SpaceComponent`. // You should use a multitude of 3 points, because each triangle is defined by defining 3 points. Points []engo.Point // BorderWidth indicates the width of the border, around EACH of the Triangles it is made out of BorderWidth float32 // BorderColor indicates the color of the border, around EACH of the Triangles it is made out of BorderColor color.Color }
ComplexTriangles is a complex form, made out of triangles.
func (ComplexTriangles) Close ¶
func (ComplexTriangles) Close()
func (ComplexTriangles) Height ¶
func (ComplexTriangles) Height() float32
func (ComplexTriangles) Texture ¶
func (ComplexTriangles) Texture() *gl.Texture
func (ComplexTriangles) Width ¶
func (ComplexTriangles) Width() float32
type Cursor ¶
type Cursor uint8
Cursor is a reference to a GLFW-cursor - to be used with the `SetCursor` method.
type EdgeScroller ¶
EdgeScroller is a System that allows for scrolling when the cursor is near the edges of the window
func (*EdgeScroller) Priority ¶
func (*EdgeScroller) Priority() int
func (*EdgeScroller) Remove ¶
func (*EdgeScroller) Remove(ecs.BasicEntity)
func (*EdgeScroller) Update ¶
func (c *EdgeScroller) Update(dt float32)
TODO: Warning doesn't get the cursor position
type EntityScroller ¶
type EntityScroller struct { *SpaceComponent TrackingBounds engo.AABB }
EntityScroller scrolls the camera to the position of a entity using its space component
func (*EntityScroller) New ¶
func (c *EntityScroller) New(*ecs.World)
New adjusts CameraBounds to the bounds of EntityScroller
func (*EntityScroller) Priority ¶
func (*EntityScroller) Priority() int
func (*EntityScroller) Remove ¶
func (*EntityScroller) Remove(ecs.BasicEntity)
func (*EntityScroller) Update ¶
func (c *EntityScroller) Update(dt float32)
Update moves the camera to the center of the space component Values are automatically clamped to TrackingBounds by the camera
type Font ¶
func (*Font) CreatePreloaded ¶
CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
type FontAtlas ¶
type FontAtlas struct { Texture *gl.Texture // XLocation contains the X-coordinate of the starting position of all characters XLocation []float32 // YLocation contains the Y-coordinate of the starting position of all characters YLocation []float32 // Width contains the width in pixels of all the characters, including the spacing between characters Width []float32 // Height contains the height in pixels of all the characters Height []float32 // TotalWidth is the total amount of pixels the `FontAtlas` is wide; useful for determining the `Viewport`, // which is relative to this value. TotalWidth float32 // TotalHeight is the total amount of pixels the `FontAtlas` is high; useful for determining the `Viewport`, // which is relative to this value. TotalHeight float32 }
A FontAtlas is a representation of some of the Font characters, as an image
type FontResource ¶
FontResource is a wrapper for `*truetype.Font` which is being passed by the the `engo.Files.Resource` method in the case of `.ttf` files.
func (FontResource) URL ¶
func (f FontResource) URL() string
type FragmentShaderCompilationError ¶
type FragmentShaderCompilationError struct {
OpenGLError string
}
FragmentShaderCompilationError is returned whenever the `LoadShader` method was unable to compile your Fragment-shader (GLSL)
func (FragmentShaderCompilationError) Error ¶
func (f FragmentShaderCompilationError) Error() string
type ImageLayer ¶
type ImageLayer struct { // Name defines the name of the image layer given in the TMX XML / Tiled Name string // Width is the integer width of each image in this layer Width int // Height is the integer height of each image in this layer Height int // Source contains the original image filename Source string // Images contains the list of all image tiles Images []*tile }
ImageLayer contains a list of its images plus all default Tiled attributes
type ImageObject ¶
type ImageObject struct {
// contains filtered or unexported fields
}
ImageObject is a pure Go implementation of a `Drawable`
func NewImageObject ¶
func NewImageObject(img *image.NRGBA) *ImageObject
NewImageObject creates a new ImageObject given the image.NRGBA reference
func (*ImageObject) Data ¶
func (i *ImageObject) Data() interface{}
Data returns the entire image.NRGBA object
func (*ImageObject) Height ¶
func (i *ImageObject) Height() int
Height returns the maximum Y coordinate of the image
func (*ImageObject) Width ¶
func (i *ImageObject) Width() int
Width returns the maximum X coordinate of the image
type KeyboardScroller ¶
type KeyboardScroller struct { ScrollSpeed float32 // contains filtered or unexported fields }
KeyboardScroller is a System that allows for scrolling when certain keys are pressed
func NewKeyboardScroller ¶
func NewKeyboardScroller(scrollSpeed float32, hori, vert string) *KeyboardScroller
func (*KeyboardScroller) BindKeyboard ¶
func (c *KeyboardScroller) BindKeyboard(hori, vert string)
func (*KeyboardScroller) Priority ¶
func (*KeyboardScroller) Priority() int
func (*KeyboardScroller) Remove ¶
func (*KeyboardScroller) Remove(ecs.BasicEntity)
func (*KeyboardScroller) Update ¶
func (c *KeyboardScroller) Update(dt float32)
type Level ¶
type Level struct { // Orientation is the parsed level orientation from the TMX XML, like orthogonal, isometric, etc. Orientation string // RenderOrder is the in Tiled specified TileMap render order, like right-down, right-up, etc. RenderOrder string // TileWidth defines the width of each tile in the level TileWidth int // TileHeight defines the height of each tile in the level TileHeight int // NextObjectId is the next free Object ID defined by Tiled NextObjectId int // TileLayers contains all TileLayer of the level TileLayers []*TileLayer // ImageLayers contains all ImageLayer of the level ImageLayers []*ImageLayer // ObjectLayers contains all ObjectLayer of the level ObjectLayers []*ObjectLayer // contains filtered or unexported fields }
Level is a parsed TMX level containing all layers and default Tiled attributes
type Mouse ¶
type Mouse struct { // X is the current x position of the mouse in the game X float32 // Y is the current y position of the mouse in the game Y float32 // ScrollX is the current scrolled position on the x component ScrollX float32 // ScrollY is the current scrolled position on the y component ScrollY float32 // Action is the currently active Action Action engo.Action // Button is which button is being pressed on the mouse Button engo.MouseButton // Modifier is whether any modifier mouse buttons are being pressed Modifer engo.Modifier }
Mouse is the representation of the physical mouse
type MouseComponent ¶
type MouseComponent struct { // Clicked is true whenever the Mouse was clicked over // the entity space in this frame Clicked bool // Released is true whenever the left mouse button is released over the // entity space in this frame Released bool // Hovered is true whenever the Mouse is hovering // the entity space in this frame. This does not necessarily imply that // the mouse button was pressed down in your entity space. Hovered bool // Dragged is true whenever the entity space was clicked, // and then the mouse started moving (while holding) Dragged bool // RightClicked is true whenever the entity space was right-clicked // in this frame RightClicked bool // RightReleased is true whenever the right mouse button is released over // the entity space in this frame. This does not necessarily imply that // the mouse button was pressed down in your entity space. RightReleased bool // Enter is true whenever the Mouse entered the entity space in that frame, // but wasn't in that space during the previous frame Enter bool // Leave is true whenever the Mouse was in the space on the previous frame, // but now isn't Leave bool // Position of the mouse at any moment this is generally used // in conjunction with Track = true MouseX float32 MouseY float32 // Set manually this to true and your mouse component will track the mouse // and your entity will always be able to receive an updated mouse // component even if its space is not under the mouse cursor // WARNING: you MUST know why you want to use this because it will // have serious performance impacts if you have many entities with // a MouseComponent in tracking mode. // This is ideally used for a really small number of entities // that must really be aware of the mouse details event when the // mouse is not hovering them Track bool // Modifier is used to store the eventual modifiers that were pressed during // the same time the different click events occurred Modifier engo.Modifier // contains filtered or unexported fields }
MouseComponent is the location for the MouseSystem to store its results; to be used / viewed by other Systems
type MouseRotator ¶
type MouseRotator struct { // RotationSpeed indicates the speed at which the rotation should happen. This is being used together with the // movement by the mouse on the X-axis, to compute the actual rotation. RotationSpeed float32 // contains filtered or unexported fields }
MouseRotator is a System that allows for zooming when the scroll wheel is used
func (*MouseRotator) Priority ¶
func (*MouseRotator) Priority() int
func (*MouseRotator) Remove ¶
func (*MouseRotator) Remove(ecs.BasicEntity)
func (*MouseRotator) Update ¶
func (c *MouseRotator) Update(float32)
type MouseSystem ¶
type MouseSystem struct {
// contains filtered or unexported fields
}
MouseSystem listens for mouse events, and changes value for MouseComponent accordingly
func (*MouseSystem) Add ¶
func (m *MouseSystem) Add(basic *ecs.BasicEntity, mouse *MouseComponent, space *SpaceComponent, render *RenderComponent)
Add adds a new entity to the MouseSystem.
- RenderComponent is only required if you're using the HUDShader on this Entity.
- SpaceComponent is required whenever you want to know specific mouse-events on this Entity (like hover, click, etc.). If you don't need those, then you can omit the SpaceComponent.
- MouseComponent is always required.
- BasicEntity is always required.
func (*MouseSystem) New ¶
func (m *MouseSystem) New(w *ecs.World)
func (*MouseSystem) Priority ¶
func (m *MouseSystem) Priority() int
Priority returns a priority higher than most, to ensure that this System runs before all others
func (*MouseSystem) Remove ¶
func (m *MouseSystem) Remove(basic ecs.BasicEntity)
func (*MouseSystem) Update ¶
func (m *MouseSystem) Update(dt float32)
type MouseZoomer ¶
type MouseZoomer struct {
ZoomSpeed float32
}
MouseZoomer is a System that allows for zooming when the scroll wheel is used
func (*MouseZoomer) Priority ¶
func (*MouseZoomer) Priority() int
func (*MouseZoomer) Remove ¶
func (*MouseZoomer) Remove(ecs.BasicEntity)
func (*MouseZoomer) Update ¶
func (c *MouseZoomer) Update(float32)
type Object ¶
type Object struct { // Id is the unique ID of each object defined by Tiled Id int // Name defines the name of the object given in Tiled Name string // Type contains the string type which was given in Tiled Type string // X holds the X float64 coordinate of the object in the map X float64 // X holds the X float64 coordinate of the object in the map Y float64 // Width is the integer width of the object Width int // Height is the integer height of the object Height int }
Object is a standard TMX object with all its default Tiled attributes
type ObjectLayer ¶
type ObjectLayer struct { // Name defines the name of the object layer given in the TMX XML / Tiled Name string // OffSetX is the parsed X offset for the object layer OffSetX float32 // OffSetY is the parsed Y offset for the object layer OffSetY float32 // Objects contains the list of (regular) Object objects Objects []*Object // PolyObjects contains the list of PolylineObject objects PolyObjects []*PolylineObject }
ObjectLayer contains a list of its standard objects as well as a list of all its polyline objects
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is a basic audio player that plays PCM data. Operations on a nil *Player are no-op, a nil *Player can be used for testing purposes.
func NewPlayer ¶
func NewPlayer(src ReadSeekCloser, format Format, samplesPerSecond int64) (*Player, error)
NewPlayer returns a new Player. It initializes the underlying audio devices and the related resources. If zero values are provided for format and sample rate values, the player determines them from the source's WAV header. An error is returned if the format and sample rate can't be determined.
The audio package is only designed for small audio sources.
func (*Player) Close ¶
Close closes the device and frees the underlying resources used by the player. It should be called as soon as the player is not in-use anymore.
func (*Player) Current ¶
Current returns the current playback position of the audio that is being played.
func (*Player) Play ¶
Play buffers the source audio to the audio device and starts to play the source. If the player paused or stopped, it reuses the previously buffered resources to keep playing from the time it has paused or stopped.
func (*Player) Seek ¶
Seek moves the play head to the given offset relative to the start of the source.
func (*Player) SetVolume ¶
SetVolume sets the volume of the player. The range of the volume is [0, 1].
type PolylineObject ¶
type PolylineObject struct { // Id is the unique ID of each polyline object defined by Tiled Id int // Name defines the name of the polyline object given in Tiled Name string // Type contains the string type which was given in Tiled Type string // X holds the X float64 coordinate of the polyline in the map X float64 // Y holds the Y float64 coordinate of the polyline in the map Y float64 // Points contains the original, unaltered points string from the TMZ XML Points string // LineBounds is the list of engo.Line objects generated from the points string LineBounds []*engo.Line }
PolylineObject is a TMX polyline object with all its default Tiled attributes
type ReadSeekCloser ¶
type ReadSeekCloser interface { io.ReadSeeker io.Closer }
ReadSeekCloser is an io.ReadSeeker and io.Closer.
type Rectangle ¶
Rectangle is a basic rectangular form; the dimensions are controlled via the `SpaceComponent`.
type RenderComponent ¶
type RenderComponent struct { // Hidden is used to prevent drawing by OpenGL Hidden bool // Scale is the scale at which to render, in the X and Y axis. Not defining Scale, will default to engo.Point{1, 1} Scale engo.Point // Color defines how much of the color-components of the texture get used Color color.Color // Drawable refers to the Texture that should be drawn Drawable Drawable // Repeat defines how to repeat the Texture if the viewport of the texture is larger than the texture itself Repeat TextureRepeating // contains filtered or unexported fields }
func (*RenderComponent) SetShader ¶
func (r *RenderComponent) SetShader(s Shader)
func (*RenderComponent) SetZIndex ¶
func (r *RenderComponent) SetZIndex(index float32)
type RenderSystem ¶
type RenderSystem struct {
// contains filtered or unexported fields
}
func (*RenderSystem) Add ¶
func (rs *RenderSystem) Add(basic *ecs.BasicEntity, render *RenderComponent, space *SpaceComponent)
func (*RenderSystem) New ¶
func (rs *RenderSystem) New(w *ecs.World)
func (*RenderSystem) Priority ¶
func (*RenderSystem) Priority() int
func (*RenderSystem) Remove ¶
func (rs *RenderSystem) Remove(basic ecs.BasicEntity)
func (*RenderSystem) Update ¶
func (rs *RenderSystem) Update(dt float32)
type Shader ¶
type Shader interface { Setup(*ecs.World) error Pre() Draw(*RenderComponent, *SpaceComponent) Post() }
type SpaceComponent ¶
type SpaceComponent struct { Position engo.Point Width float32 Height float32 Rotation float32 // angle in degrees for the rotation to apply clockwise }
func (SpaceComponent) AABB ¶
func (sc SpaceComponent) AABB() engo.AABB
AABB returns the minimum and maximum point for the given SpaceComponent. It hereby takes into account the rotation of the Component - it may very well be that the Minimum as given by engo.AABB, is smaller than the Position of the object (i.e. when rotated).
This basically returns the "outer rectangle" of the plane defined by the `SpaceComponent`. Since this returns two points, a minimum and a maximum, the "rectangle" resulting from this `AABB`, is not rotated in any way. However, depending on the rotation of the `SpaceComponent`, this `AABB` may be larger than the original `SpaceComponent`.
func (*SpaceComponent) Center ¶
func (sc *SpaceComponent) Center(p engo.Point)
Center positions the space component according to its center instead of its top-left point (this avoids doing the same math each time in your systems)
func (SpaceComponent) Contains ¶
func (sc SpaceComponent) Contains(p engo.Point) bool
Contains indicates whether or not the given point is within the rectangular plane as defined by this `SpaceComponent`. If it's on the border, it is considered "not within".
func (SpaceComponent) Corners ¶
func (sc SpaceComponent) Corners() (points [4]engo.Point)
Corners returns the location of the four corners of the rectangular plane defined by the `SpaceComponent`, taking into account any possible rotation.
type Spritesheet ¶
Spritesheet is a class that stores a set of tiles from a file, used by tilemaps and animations
func NewSpritesheetFromFile ¶
func NewSpritesheetFromFile(textureName, textName string) *Spritesheet
NewSpritesheetFromFile is a simple handler for creating a new spritesheet from a file textureName is the name of a texture already preloaded with engo.Files.Add
func NewSpritesheetFromTexture ¶
func NewSpritesheetFromTexture(tr *TextureResource, metadata *TextResource) *Spritesheet
func (*Spritesheet) Cell ¶
func (s *Spritesheet) Cell(index int) Texture
Cell gets the region at the index i, updates and pulls from cache if need be
func (*Spritesheet) CellCount ¶
func (s *Spritesheet) CellCount() int
func (*Spritesheet) Cells ¶
func (s *Spritesheet) Cells() []Texture
func (*Spritesheet) Drawable ¶
func (s *Spritesheet) Drawable(index int) Drawable
func (*Spritesheet) Drawables ¶
func (s *Spritesheet) Drawables() []Drawable
type TMXImageLayer ¶
type TMXImageLayer struct { // Name of the image layer in Tiled Name string `xml:"name,attr"` // X holds the defined X coordinate in Tiled X float64 `xml:"x,attr"` // Y holds the defined Y coordinate in Tiled Y float64 `xml:"y,attr"` // ImageSrc contains the TMXImageSrc which defines the image filename ImageSrc TMXImageSrc `xml:"image"` }
TMXImageLayer represents an image layer parsed from the TileMap XML
type TMXImageSrc ¶
type TMXImageSrc struct { // Source holds the URI of the image Source string `xml:"source,attr"` // Width is the integer width of the image Width int `xml:"width,attr"` // Height is the integer height of the image Height int `xml:"height,attr"` }
TMXImageSrc represents the actual image source of an image layer
type TMXLevel ¶
type TMXLevel struct { // Orientation is the parsed level orientation from the TMX XML, like orthogonal Orientation string `xml:"orientation,attr"` // RenderOrder is the in Tiled specified TileMap render order, like right-down RenderOrder string `xml:"renderorder,attr"` // Width is the integer width of the parsed level Width int `xml:"width,attr"` // Height is the integer height of the parsed level Height int `xml:"height,attr"` // TileWidth defines the width of each tile in the level TileWidth int `xml:"tilewidth,attr"` // TileHeight defines the height of each tile in the level TileHeight int `xml:"tileheight,attr"` // NextObjectId is the next free Object ID defined by Tiled NextObjectId int `xml:"nextobjectid,attr"` // Tilesets conatins a list of all parsed TMXTileset objects Tilesets []TMXTileset `xml:"tileset"` // TileLayers conatins a list of all parsed TMXTileLayer objects TileLayers []TMXTileLayer `xml:"layer"` // ImageLayers conatins a list of all parsed TMXImageLayer objects ImageLayers []TMXImageLayer `xml:"imagelayer"` // ObjectLayers conatins a list of all parsed TMXObjectLayer objects ObjectLayers []TMXObjectLayer `xml:"objectgroup"` }
TMXLevel containing all layers and default Tiled attributes
type TMXObject ¶
type TMXObject struct { // Id is the unique ID of each object defined by Tiled Id int `xml:"id,attr"` // Name defines the name of the object given in Tiled Name string `xml:"name,attr"` // Type contains the string type which was given in Tiled Type string `xml:"type,attr"` // X holds the X float64 coordinate of the object in the map X float64 `xml:"x,attr"` // Y holds the Y float64 coordinate of the object in the map Y float64 `xml:"y,attr"` // Width is the integer width of the object Width int `xml:"width,attr"` // Height is the integer height of the object Height int `xml:"height,attr"` // Polyline contains the TMXPolyline object if the parsed object has a polyline points string Polyline TMXPolyline `xml:"polyline"` }
TMXObject represents a TMX object with all default Tiled attributes
type TMXObjectLayer ¶
type TMXObjectLayer struct { // Name of the object layer in Tiled Name string `xml:"name,attr"` // Objects contains the list all objects in this layer Objects []TMXObject `xml:"object"` // OffSetX is the parsed X offset for the object layer OffSetX float32 `xml:"offsetx"` // OffSetY is the parsed Y offset for the object layer OffSetY float32 `xml:"offsety"` }
TMXObjectLayer following the Object Layer naming convention in Tiled
type TMXPolyline ¶
type TMXPolyline struct { // Points contains the original, unaltered points string from the TMZ XML Points string `xml:"points,attr"` }
TMXPolyline represents a TMX Polyline object with its Points values
type TMXResource ¶
type TMXResource struct { // Level holds the reference to the parsed TMX level Level *Level // contains filtered or unexported fields }
TMXResource contains a level created from a Tile Map XML
type TMXTileLayer ¶
type TMXTileLayer struct { // Name of the tile layer in Tiled Name string `xml:"name,attr"` // Width is the integer width of each tile in this layer Width int `xml:"width,attr"` // Height is the integer height of each tile in this layer Height int `xml:"height,attr"` // TileMapping contains the generated tilemapping list TileMapping []uint32 // CompData is a temporary list used to fill TileMapping CompData []byte `xml:"data"` }
TMXTileLayer represents a tile layer parsed from the TileMap XML
type TMXTileset ¶
type TMXTileset struct { // Firstgid is the first assigned gid of the tileset Firstgid int `xml:"firstgid,attr"` // Name of the tileset in Tiled Name string `xml:"name,attr"` // TileWidth defines the width of each tile TileWidth int `xml:"tilewidth,attr"` // TileHeight defines the height of each tile TileHeight int `xml:"tileheight,attr"` // TileCount holds the total tile count in this tileset TileCount int `xml:"tilecount,attr"` // ImageSrc contains the TMXTilesetSrc which defines the tileset image ImageSrc TMXTilesetSrc `xml:"image"` // Image holds the reference of the tileset's TextureResource Image *TextureResource }
TMXTileset contains the tileset resource parsed from the TileMap XML
type TMXTilesetSrc ¶
type TMXTilesetSrc struct { // Source holds the URI of the tileset image Source string `xml:"source,attr"` // Width of each tile in the tileset image Width int `xml:"width,attr"` // Height of each tile in the tileset image Height int `xml:"height,attr"` }
TMXTilesetSrc is just used to create levelTileset->Image
type Text ¶
type Text struct { // Font is the reference to the font you're using to render this. This includes the color, as well as the font size. Font *Font // Text is the actual text you want to draw. This may include newlines (\n). Text string // LineSpacing is the amount of additional spacing there is between the lines (when `Text` consists of multiple lines), // relative to the `Size` of the `Font`. LineSpacing float32 // LetterSpacing is the amount of additional spacing there is between the characters, relative to the `Size` of // the `Font`. LetterSpacing float32 // RightToLeft is an experimental variable used to indicate that subsequent characters come to the left of the // previous character. RightToLeft bool }
Text represents a string drawn onto the screen, as used by the `TextShader`.
type TextResource ¶
type TextResource struct { // Text holds the text read from the file Text string // contains filtered or unexported fields }
TextResource contains a level created from a Tile Map XML
func (TextResource) URL ¶
func (r TextResource) URL() string
URL retrieves the url to the .text file
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents a texture loaded in the GPU RAM (by using OpenGL), which defined dimensions and viewport
func LoadedSprite ¶
LoadedSprite loads the texture-reference from `engo.Files`, and wraps it in a `*Texture`. This method is intended for image-files which represent entire sprites.
func NewTextureSingle ¶
NewTextureSingle sends the image to the GPU and returns a `Texture` with a viewport for single-sprite images
type TextureRepeating ¶
type TextureRepeating uint8
const ( ClampToEdge TextureRepeating = iota ClampToBorder Repeat MirroredRepeat )
type TextureResource ¶
type TextureResource struct { Texture *gl.Texture Width float32 Height float32 // contains filtered or unexported fields }
func NewTextureResource ¶
func NewTextureResource(img Image) TextureResource
NewTextureResource sends the image to the GPU and returns a `TextureResource` for easy access
func (TextureResource) URL ¶
func (t TextureResource) URL() string
type TileLayer ¶
type TileLayer struct { // Name defines the name of the tile layer given in the TMX XML / Tiled Name string // Width is the integer width of each tile in this layer Width int // Height is the integer height of each tile in this layer Height int // Tiles contains the list of tiles Tiles []*tile }
TileLayer contains a list of its tiles plus all default Tiled attributes
type Triangle ¶
type Triangle struct { TriangleType TriangleType BorderWidth float32 BorderColor color.Color }
Triangle is a basic triangular form; the "point" of the triangle is pointing to the top
type TriangleType ¶
type TriangleType uint8
const ( // Indicates a Triangle where two sides have equal length TriangleIsosceles TriangleType = iota // Indicates a Triangles where one angle is at 90 degrees TriangleRight )
type VertexShaderCompilationError ¶
type VertexShaderCompilationError struct {
OpenGLError string
}
VertexShaderCompilationError is returned whenever the `LoadShader` method was unable to compile your Vertex-shader (GLSL)
func (VertexShaderCompilationError) Error ¶
func (v VertexShaderCompilationError) Error() string