Documentation ¶
Overview ¶
Package common contains ECS implementations of commonly used game systems.
The current package contains ECS systems for:
animation
audio (in progress)
rendering
camera control
mouse detection (clicks, hover, dragging, etc)
collision detection
fonts
sprite sheets
TMX maps
Index ¶
- Constants
- Variables
- func AddShader(s Shader)
- func GetMasterVolume() float64
- 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 SetMasterVolume(volume float64)
- 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 (c *AnimationComponent) GetAnimationComponent() *AnimationComponent
- func (ac *AnimationComponent) NextFrame()
- func (ac *AnimationComponent) SelectAnimationByAction(action *Animation)
- func (ac *AnimationComponent) SelectAnimationByName(name string)
- type AnimationFace
- type AnimationSystem
- type Animationable
- type AudioComponent
- type AudioFace
- type AudioSystem
- func (a *AudioSystem) Add(basic *ecs.BasicEntity, audio *AudioComponent)
- func (a *AudioSystem) AddByInterface(i ecs.Identifier)
- func (a *AudioSystem) Close()
- func (a *AudioSystem) New(w *ecs.World)
- func (a *AudioSystem) Pause()
- func (a *AudioSystem) Remove(basic ecs.BasicEntity)
- func (a *AudioSystem) Restart()
- func (a *AudioSystem) Update(dt float32)
- type Audioable
- type BasicFace
- type Blendmap
- type CameraAxis
- type CameraMessage
- type CameraSystem
- func (cam *CameraSystem) Angle() float32
- func (cam *CameraSystem) FollowEntity(basic *ecs.BasicEntity, space *SpaceComponent, trackRotation bool)
- func (cam *CameraSystem) New(w *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 CollisionFace
- type CollisionGroup
- type CollisionMessage
- type CollisionSystem
- type Collisionable
- type ComplexTriangles
- type CullingShader
- type Cursor
- type Curve
- type Drawable
- type EdgeScroller
- type Ellipse
- type EntityScroller
- type FPSSystem
- type Font
- type FontAtlas
- type FontResource
- type FragmentShaderCompilationError
- type Framebuffer
- type Image
- type ImageLayer
- type ImageObject
- type KeyboardScroller
- type Level
- type Mouse
- type MouseComponent
- type MouseFace
- type MouseRotator
- type MouseSystem
- func (m *MouseSystem) Add(basic *ecs.BasicEntity, mouse *MouseComponent, space *SpaceComponent, ...)
- func (m *MouseSystem) AddByInterface(i ecs.Identifier)
- func (m *MouseSystem) New(w *ecs.World)
- func (m *MouseSystem) Priority() int
- func (m *MouseSystem) Remove(basic ecs.BasicEntity)
- func (m *MouseSystem) Update(dt float32)
- type MouseZoomer
- type Mouseable
- type NewCameraMessage
- type NotAnimationComponent
- type NotAnimationable
- type NotAudioComponent
- type NotAudioable
- type NotCollisionComponent
- type NotCollisionable
- type NotMouseComponent
- type NotMouseable
- type NotRenderComponent
- type NotRenderable
- type Object
- type ObjectLayer
- type Player
- func (p *Player) Close() error
- func (p *Player) Current() time.Duration
- func (p *Player) GetVolume() float64
- func (p *Player) IsPlaying() bool
- func (p *Player) Pause()
- func (p *Player) Play()
- func (p *Player) Rewind() error
- func (p *Player) Seek(offset time.Duration) error
- func (p *Player) SetVolume(volume float64)
- func (p *Player) URL() string
- type Property
- type Rectangle
- type RenderBuffer
- type RenderComponent
- func (c *RenderComponent) GetRenderComponent() *RenderComponent
- func (r *RenderComponent) SetMagFilter(z ZoomFilter)
- func (r *RenderComponent) SetMinFilter(z ZoomFilter)
- func (r *RenderComponent) SetShader(s Shader)
- func (r *RenderComponent) SetZIndex(index float32)
- func (r *RenderComponent) Shader() Shader
- type RenderFace
- type RenderSystem
- func (rs *RenderSystem) Add(basic *ecs.BasicEntity, render *RenderComponent, space *SpaceComponent)
- func (rs *RenderSystem) AddByInterface(i ecs.Identifier)
- func (rs *RenderSystem) EntityExists(basic *ecs.BasicEntity) int
- func (rs *RenderSystem) New(w *ecs.World)
- func (*RenderSystem) Priority() int
- func (rs *RenderSystem) Remove(basic ecs.BasicEntity)
- func (rs *RenderSystem) Update(dt float32)
- type RenderTexture
- type Renderable
- type Shader
- type Shape
- type SpaceComponent
- func (sc SpaceComponent) AABB() engo.AABB
- func (sc *SpaceComponent) AddShape(shape Shape)
- func (sc *SpaceComponent) Center() engo.Point
- func (sc SpaceComponent) Contains(p engo.Point) bool
- func (sc SpaceComponent) Corners() (points [4]engo.Point)
- func (c *SpaceComponent) GetSpaceComponent() *SpaceComponent
- func (sc SpaceComponent) Overlaps(other SpaceComponent, thisTolerance, otherTolerance engo.Point) (bool, engo.Point)
- func (sc *SpaceComponent) SetCenter(p engo.Point)
- type SpaceFace
- type SpriteRegion
- type Spritesheet
- func LoadedSpritesheet(url string) (*Spritesheet, error)
- func NewAsymmetricSpritesheetFromFile(textureName string, spriteRegions []SpriteRegion) *Spritesheet
- func NewAsymmetricSpritesheetFromTexture(tr *TextureResource, spriteRegions []SpriteRegion) *Spritesheet
- func NewSpritesheetFromFile(textureName string, cellWidth, cellHeight int) *Spritesheet
- func NewSpritesheetFromTexture(tr *TextureResource, cellWidth, cellHeight int) *Spritesheet
- func NewSpritesheetWithBorderFromFile(textureName string, cellWidth, cellHeight, borderWidth, borderHeight int) *Spritesheet
- func NewSpritesheetWithBorderFromTexture(tr *TextureResource, cellWidth, cellHeight, borderWidth, borderHeight int) *Spritesheet
- type SubTexture
- type TMXCircle
- type TMXLine
- type TMXResource
- type TMXText
- type Text
- type Texture
- type TextureAtlas
- type TextureAtlasResource
- type TexturePack
- type TextureRepeating
- type TextureResource
- type Tile
- type TileLayer
- type Triangle
- type TriangleType
- type VertexShaderCompilationError
- type ZoomFilter
Constants ¶
const ( // MouseRotatorPriority is the priority for the MouseRotatorSystem. // Priorities determine the order in which the system is updated. MouseRotatorPriority = 100 // MouseZoomerPriority is the priority for he MouseZoomerSystem. // Priorities determine the order in which the system is updated. MouseZoomerPriority = 110 // EdgeScrollerPriority is the priority for the EdgeScrollerSystem. // Priorities determine the order in which the system is updated. EdgeScrollerPriority = 120 // KeyboardScrollerPriority is the priority for the KeyboardScrollerSystem. // Priorities determine the order in which the system is updated. KeyboardScrollerPriority = 130 // EntityScrollerPriority is the priority for the EntityScrollerSystem. // Priorities determine the order in which the system is updated. EntityScrollerPriority = 140 )
const ( //CursorNone is no visible cursor. CursorNone = iota //CursorArrow is an arrow cursor. CursorArrow //CursorCrosshair is a crosshair cursor. CursorCrosshair //CursorHand is a hand cursor. CursorHand //CursorIBeam is a text-editor I cursor. CursorIBeam //CursorHResize is the horizontal resize window cursor. CursorHResize //CursorVResize is the vertical resize window cursor. CursorVResize )
const ( // MaxSprites is the maximum number of sprites that can comprise a single batch. // 32767 is the max vertex index in OpenGL. Since each sprite has 4 vertices, // 32767 / 4 = 8191 max sprites. MaxSprites = 8191 )
const MouseSystemPriority = 100
MouseSystemPriority is the priority of the MouseSystem
const (
// RenderSystemPriority is the priority of the RenderSystem
RenderSystemPriority = -1000
)
Variables ¶
var ( // MinZoom is the closest the camera position can be relative to the // rendered surface. Smaller numbers of MinZoom allows greater // perceived zooming "in". MinZoom float32 = 0.25 // MaxZoom is the farthest the camera position can be relative to the // rendered surface. Larger numbers of MaxZoom allows greater // perceived zooming "out". MaxZoom float32 = 3 // CameraBounds is the bounding box of the camera CameraBounds engo.AABB )
var ( // UnicodeCap is the amount of unicode characters the fonts will be able to use, starting from index 0. UnicodeCap = 200 // DefaultShader is the shader picked when no other shader is used. DefaultShader = &basicShader{cameraEnabled: true} // HUDShader is the shader used for HUD elements. HUDShader = &basicShader{cameraEnabled: false} // LegacyShader is the shader used for drawing shapes. LegacyShader = &legacyShader{cameraEnabled: true} // LegacyHUDShader is the shader used for drawing shapes on the HUD. LegacyHUDShader = &legacyShader{cameraEnabled: false} // TextShader is the shader used to draw fonts from a FontAtlas TextShader = &textShader{cameraEnabled: true} // TextHUDShader is the shader used to draw fonts from a FontAtlas on the HUD. TextHUDShader = &textShader{cameraEnabled: false} // BlendmapShader is a shader used to create blendmaps BlendmapShader = &blendmapShader{cameraEnabled: true} )
var SampleRate = 44100
SampleRate is the sample rate at which the player plays audio. Any audios resource that is added to the system is resampled to this sample rate. To change the sample rate, you must do so BEFORE adding the audio system to the world.
Functions ¶
func AddShader ¶
func AddShader(s Shader)
AddShader adds a shader to the list of shaders for initalization. They should be added before the Rendersystem is added, such as in the scene's Preload.
func GetMasterVolume ¶
func GetMasterVolume() float64
GetMasterVolume gets the master volume of the audio system.
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 IsIntersecting ¶
IsIntersecting tells if two engo.AABBs intersect.
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 MinimumTranslation ¶
MinimumTranslation tells how much an entity has to move to no longer overlap another entity.
func SetBackground ¶
SetBackground sets the OpenGL ClearColor to the provided color.
func SetMasterVolume ¶
func SetMasterVolume(volume float64)
SetMasterVolume sets the master volume. The masterVolume is multiplied by all the other volumes to get the volume of each entity played. Value must be between 0 and 1 or else it doesn't set.
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 CurrentFrame int // The current animation frame number 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) GetAnimationComponent ¶
func (c *AnimationComponent) GetAnimationComponent() *AnimationComponent
GetAnimationComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
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 AnimationFace ¶
type AnimationFace interface {
GetAnimationComponent() *AnimationComponent
}
AnimationFace allows typesafe Access to an Annonymous child AnimationComponent
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) AddByInterface ¶
func (a *AnimationSystem) AddByInterface(i ecs.Identifier)
AddByInterface Allows an Entity to be added directly using the Animtionable interface. which every entity containing the BasicEntity,AnimationComponent,and RenderComponent anonymously, automatically satisfies.
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 Animationable ¶
type Animationable interface { BasicFace AnimationFace RenderFace }
Animationable is the required interface for AnimationSystem.AddByInterface method
type AudioComponent ¶
type AudioComponent struct {
Player *Player
}
AudioComponent is a Component which is used by the AudioSystem
func (*AudioComponent) GetAudioComponent ¶
func (c *AudioComponent) GetAudioComponent() *AudioComponent
GetAudioComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
type AudioFace ¶
type AudioFace interface {
GetAudioComponent() *AudioComponent
}
AudioFace allows typesafe access to an anonymouse child AudioComponent
type AudioSystem ¶
type AudioSystem struct {
// 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)
Add adds an entity to the AudioSystem
func (*AudioSystem) AddByInterface ¶
func (a *AudioSystem) AddByInterface(i ecs.Identifier)
AddByInterface Allows an Entity to be added directly using the Audioable interface, which every entity containing the BasicEntity and AnimationComponent anonymously, automatically satisfies.
func (*AudioSystem) Close ¶
func (a *AudioSystem) Close()
Close closes the AudioSystem's loop. After this is called the AudioSystem can no longer play audio. Blocks until loop actually closes.
func (*AudioSystem) New ¶
func (a *AudioSystem) New(w *ecs.World)
New is called when the AudioSystem is added to the world.
func (*AudioSystem) Pause ¶
func (a *AudioSystem) Pause()
Pause pauses the AudioSystem's loop. Call Restart to continue playing audio.
func (*AudioSystem) Remove ¶
func (a *AudioSystem) Remove(basic ecs.BasicEntity)
Remove removes an entity from the AudioSystem
func (*AudioSystem) Restart ¶
func (a *AudioSystem) Restart()
Restart restarts the AudioSystem's loop when it's paused.
func (*AudioSystem) Update ¶
func (a *AudioSystem) Update(dt float32)
Update doesn't do anything since audio is run on it's own thread
type BasicFace ¶
type BasicFace interface { ID() uint64 GetBasicEntity() *ecs.BasicEntity }
BasicFace is the means of accessing the ecs.BasicEntity class , it also has the ID method, to simplify, finding an item within a system
type Blendmap ¶
type Blendmap struct { *TexturePack Map *Texture }
type CameraAxis ¶
type CameraAxis uint8
CameraAxis is the axis at which the Camera can/has to move.
const ( // XAxis is the x-axis of the camera XAxis CameraAxis = iota // YAxis is the y-axis of the camera. YAxis // ZAxis is the z-axis of the camera. ZAxis // Angle is the angle the camera is rotated by. 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 implements the engo.Message interface.
type CameraSystem ¶
type CameraSystem struct {
// contains filtered or unexported fields
}
CameraSystem is a System that manages the state of the virtual camera. Only one CameraSystem can be in a World at a time. If more than one CameraSystem is added to the World, it will panic.
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, trackRotation bool)
FollowEntity sets the camera to follow the entity with BasicEntity basic and SpaceComponent space.
func (*CameraSystem) New ¶
func (cam *CameraSystem) New(w *ecs.World)
New initializes the CameraSystem. New initializes the CameraSystem.
func (*CameraSystem) Remove ¶
func (cam *CameraSystem) Remove(ecs.BasicEntity)
Remove does nothing since the CameraSystem has only one entity, the camera itself. This is here to implement the ecs.System interface.
func (*CameraSystem) Update ¶
func (cam *CameraSystem) Update(dt float32)
Update updates the camera. lLong tasks are attempted to update incrementally in batches.
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).
func (Circle) Close ¶
func (Circle) Close()
Close does nothing, because there's no Texture on the GPU. This implements the Drawable interface.
func (Circle) Texture ¶
Texture always returns nil. Circle is drawable without a Texture. This implements the Drawable interface.
type CollisionComponent ¶
type CollisionComponent struct { // if a.Main & (bitwise) b.Group, items can collide // if a.Main == 0, it will not loop for other items Main, Group CollisionGroup Extra engo.Point Collides CollisionGroup }
CollisionComponent keeps track of the entity's collisions.
Main tells the system to check all collisions against this entity.
Group tells which collision group his entity belongs to.
Extra is the allowed buffer for detecting collisions.
Collides is all the groups this component collides with ORed together
func (*CollisionComponent) GetCollisionComponent ¶
func (c *CollisionComponent) GetCollisionComponent() *CollisionComponent
GetCollisionComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
type CollisionFace ¶
type CollisionFace interface {
GetCollisionComponent() *CollisionComponent
}
CollisionFace allows typesafe access to an anonymous CollisionComponent
type CollisionGroup ¶
type CollisionGroup byte
CollisionGroup is intended to be used in bitwise comparisons The user is expected to create a const ( a = 1 << iota \n b \n c etc) for the different kinds of collisions they hope to use
type CollisionMessage ¶
type CollisionMessage struct { Entity collisionEntity To collisionEntity Groups CollisionGroup }
CollisionMessage is sent whenever a collision is detected by the CollisionSystem.
func (CollisionMessage) Type ¶
func (CollisionMessage) Type() string
Type implements the engo.Message interface
type CollisionSystem ¶
type CollisionSystem struct { // Solids, used to tell which collisions should be treated as solid by bitwise comparison. // if a.Main & b.Group & sys.Solids{ Collisions are treated as solid. } Solids CollisionGroup // contains filtered or unexported fields }
CollisionSystem is a system that detects collisions between entities, sends a message if collisions are detected, and updates their SpaceComponent so entities cannot pass through Solids.
func (*CollisionSystem) Add ¶
func (c *CollisionSystem) Add(basic *ecs.BasicEntity, collision *CollisionComponent, space *SpaceComponent)
Add adds an entity to the CollisionSystem. To be added, the entity has to have a basic, collision, and space component.
func (*CollisionSystem) AddByInterface ¶
func (c *CollisionSystem) AddByInterface(i ecs.Identifier)
AddByInterface Provides a simple way to add an entity to the system that satisfies Collisionable. Any entity containing, BasicEntity,CollisionComponent, and SpaceComponent anonymously, automatically does this.
func (*CollisionSystem) Remove ¶
func (c *CollisionSystem) Remove(basic ecs.BasicEntity)
Remove removes an entity from the CollisionSystem.
func (*CollisionSystem) Update ¶
func (c *CollisionSystem) Update(dt float32)
Update checks the entities for collision with eachother. Only Main entities are check for collision explicitly. If one of the entities are solid, the SpaceComponent is adjusted so that the other entities don't pass through it.
type Collisionable ¶
type Collisionable interface { BasicFace CollisionFace SpaceFace }
Collisionable is the required interface for the CollisionSystem.AddByInterface method
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()
Close does nothing, because there's no Texture on the GPU. This implements the Drawable interface.
func (ComplexTriangles) Height ¶
func (ComplexTriangles) Height() float32
Height always returns 0. This implements the Drawable interface.
func (ComplexTriangles) Texture ¶
func (ComplexTriangles) Texture() *gl.Texture
Texture always returns nil. ComplexTriangles is drawable without a Texture. This implements the Drawable interface.
func (ComplexTriangles) View ¶
func (ComplexTriangles) View() (float32, float32, float32, float32)
View always returns 0, 0, 1, 1. This implements the Drawable interface.
func (ComplexTriangles) Width ¶
func (ComplexTriangles) Width() float32
Width always returns 0. This implements the Drawable interface.
type CullingShader ¶
type CullingShader interface { Shader // PrepareCulling is called once per frame for the shader to initialize culling calculation. PrepareCulling() ShouldDraw(*RenderComponent, *SpaceComponent) bool }
CullingShader when implemented can be used in the RenderSystem to test if an entity should be rendered.
type Cursor ¶
type Cursor uint8
Cursor is a reference to a GLFW-cursor - to be used with the `SetCursor` method.
type Curve ¶
Curve is a beizer curve defined by the points provided. These points are relative to the SpaceComponent provided, so moving that will move the Curve without adjusting the Points for the beizer curve. The first control point is the top-left corner of the space component, and the last control point is the bottom-right corner. To do third and fourth order, add points to Points.
func (Curve) Close ¶
func (Curve) Close()
Close does nothing, because there's no Texture on the GPU. This implements the Drawable interface.
func (Curve) Texture ¶
Texture always returns nil. Curve is drawable without a Texture. This implements the Drawable interface.
type Drawable ¶
type Drawable interface { Texture() *gl.Texture Width() float32 Height() float32 View() (float32, float32, float32, float32) Close() }
Drawable is that which can be rendered to OpenGL.
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
Priority implements the ecs.Prioritizer interface.
func (*EdgeScroller) Remove ¶
func (*EdgeScroller) Remove(ecs.BasicEntity)
Remove does nothing because EdgeScroller has no entities. It implements the ecs.System interface.
func (*EdgeScroller) Update ¶
func (c *EdgeScroller) Update(dt float32)
Update moves the camera based on the position of the mouse. If the mouse is on the edge of the screen, the camera moves towards that edge. TODO: Warning doesn't get the cursor position
type Ellipse ¶
Ellipse represnets an ellpitical shape. Cx and Cy are the x and y coordinates of the center of the ellipse. Rx and Ry are the x and y radii of the ellipse. N is the number of faces used for a polymeric representation of the ellipse for collision detection.
type EntityScroller ¶
type EntityScroller struct { *SpaceComponent TrackingBounds engo.AABB Rotation bool }
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
Priority implements the ecs.Prioritizer interface.
func (*EntityScroller) Remove ¶
func (*EntityScroller) Remove(ecs.BasicEntity)
Remove does nothing because the EntityScroller system has no entities. This implements the ecs.System interface.
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 FPSSystem ¶
type FPSSystem struct {
Display, Terminal bool
Font *Font // Font used to display the FPS to the screen, defaults to gomonobold
// contains filtered or unexported fields
}
FPSSystem is a system for debugging that displays FPS to either the screen or the terminal.
func (*FPSSystem) Add ¶
func (*FPSSystem) Add()
Add doesn't do anything since New creates the only entity used
func (*FPSSystem) DisplayString ¶
DisplayString returns the display string in the format FPS: 60
func (*FPSSystem) Remove ¶
func (*FPSSystem) Remove(b ecs.BasicEntity)
Remove doesn't do anything since New creates the only entity used
type Font ¶
type Font struct { URL string Size float64 BG color.Color FG color.Color TTF *truetype.Font // contains filtered or unexported fields }
Font keeps track of a specific Font. Fonts are explicit instances of a font file, including the Size and Color. A separate font will have to be generated to get different sizes and colors of the same font file.
func LoadedFont ¶
LoadedFont returns a Font that was previously loaded via CreatePreloaded
func (*Font) CreatePreloaded ¶
CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
func (*Font) GenerateFontAtlas ¶
GenerateFontAtlas generates the font atlas for this given font, using the first `c` Unicode characters. This should only be used if you are writing your own custom text shader.
func (*Font) RenderNRGBA ¶
RenderNRGBA returns an *image.NRGBA in the Font based on the input string.
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 // OffsetX is the offset of the glyph and the x-coordinate OffsetX []float32 // RightSide is the space left to the right of the glyph RightSide []float32 // OffsetY is the offset of the glyph and the y-coordinate OffsetY []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
URL returns the file path for the FontResource.
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
Error implements the error interface.
type Framebuffer ¶
type Framebuffer struct {
// contains filtered or unexported fields
}
func CreateFramebuffer ¶
func CreateFramebuffer() *Framebuffer
func (*Framebuffer) Close ¶
func (fb *Framebuffer) Close()
func (*Framebuffer) Destroy ¶
func (fb *Framebuffer) Destroy()
func (*Framebuffer) Open ¶
func (fb *Framebuffer) Open(width, height int)
type ImageLayer ¶
type ImageLayer struct { // Name defines the name of the image layer given in the TMX XML / Tiled Name string // Source contains the original image filename Source string // Images contains the list of all image tiles Images []*Tile // Opacity is the opacity of the layer from [0,1] Opacity float32 // Visible is if the layer is visible Visible bool // XOffset is the x-offset of the layer OffSetX float32 // YOffset is the y-offset of the layer OffSetY float32 // Properties are the custom properties of the layer Properties []Property }
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
NewKeyboardScroller creates a new KeyboardScroller system using the provided scrollSpeed, and horizontal and vertical axes.
func (*KeyboardScroller) BindKeyboard ¶
func (c *KeyboardScroller) BindKeyboard(hori, vert string)
BindKeyboard sets the vertical and horizontal axes used by the KeyboardScroller.
func (*KeyboardScroller) Priority ¶
func (*KeyboardScroller) Priority() int
Priority implememts the ecs.Prioritizer interface.
func (*KeyboardScroller) Remove ¶
func (*KeyboardScroller) Remove(ecs.BasicEntity)
Remove does nothing because the KeyboardScroller system has no entities. It implements the ecs.System interface.
func (*KeyboardScroller) Update ¶
func (c *KeyboardScroller) Update(dt float32)
Update updates the camera based on keyboard input.
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 // Properties are custom properties of the level Properties []Property // 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 left-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 // RightDragged is true whenever the entity space was right-clicked, // and then the mouse started moving (while holding) RightDragged 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
func (*MouseComponent) GetMouseComponent ¶
func (c *MouseComponent) GetMouseComponent() *MouseComponent
GetMouseComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
type MouseFace ¶
type MouseFace interface {
GetMouseComponent() *MouseComponent
}
MouseFace allows typesafe access to an Anonymous child MouseComponent
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 rotating the camera based on pressing down the scroll wheel.
func (*MouseRotator) Priority ¶
func (*MouseRotator) Priority() int
Priority implements the ecs.Prioritizer interface.
func (*MouseRotator) Remove ¶
func (*MouseRotator) Remove(ecs.BasicEntity)
Remove does nothing because MouseRotator has no entities. This implements the ecs.System interface.
func (*MouseRotator) Update ¶
func (c *MouseRotator) Update(float32)
Update rotates the camera if the scroll wheel is pressed down.
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) AddByInterface ¶
func (m *MouseSystem) AddByInterface(i ecs.Identifier)
AddByInterface adds the Entity to the system as long as it satisfies, Mouseable. Any Entity containing a BasicEntity,MouseComponent, and RenderComponent, automatically does this.
func (*MouseSystem) New ¶
func (m *MouseSystem) New(w *ecs.World)
New initializes the MouseSystem. It is run before any updates.
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)
Remove removes an entity from the MouseSystem.
func (*MouseSystem) Update ¶
func (m *MouseSystem) Update(dt float32)
Update updates all the entities in the MouseSystem.
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
Priority implements the ecs.Prioritizer interface.
func (*MouseZoomer) Remove ¶
func (*MouseZoomer) Remove(ecs.BasicEntity)
Remove does nothing because MouseZoomer has no entities. This implements the ecs.System interface.
func (*MouseZoomer) Update ¶
func (c *MouseZoomer) Update(float32)
Update zooms the camera in and out based on the movement of the scroll wheel.
type Mouseable ¶
type Mouseable interface { BasicFace MouseFace SpaceFace RenderFace }
Mouseable is the required interface for the MouseSystem AddByInterface method
type NewCameraMessage ¶
type NewCameraMessage struct{}
NewCameraMessage is a message that is sent out whenever the camera system changes, such as when a new world is created or scenes are switched.
func (NewCameraMessage) Type ¶
func (NewCameraMessage) Type() string
Type implements the engo.Message interface.
type NotAnimationComponent ¶
type NotAnimationComponent struct{}
NotAnimationComponent is used to flag an entity as not in the AnimationSystem even if it has the proper components
func (*NotAnimationComponent) GetNotAnimationComponent ¶
func (n *NotAnimationComponent) GetNotAnimationComponent() *NotAnimationComponent
GetNotAnimationComponent implements the NotAnimationable interface
type NotAnimationable ¶
type NotAnimationable interface {
GetNotAnimationComponent() *NotAnimationComponent
}
NotAnimationable is an interface used to flag an entity as not in the AnimationSystem even if it has the proper components
type NotAudioComponent ¶
type NotAudioComponent struct{}
NotAudioComponent is used to flag an entity as not in the AudioSystem even if it has the proper components
func (*NotAudioComponent) GetNotAudioComponent ¶
func (n *NotAudioComponent) GetNotAudioComponent() *NotAudioComponent
GetNotAudioComponent implements the NotAudioable interface
type NotAudioable ¶
type NotAudioable interface {
GetNotAudioComponent() *NotAudioComponent
}
NotAudioable is an interface used to flag an entity as not in the AudioSystem even if it has the proper components
type NotCollisionComponent ¶
type NotCollisionComponent struct{}
NotCollisionComponent is used to flag an entity as not in the CollisionSystem even if it has the proper components
func (*NotCollisionComponent) GetNotCollisionComponent ¶
func (n *NotCollisionComponent) GetNotCollisionComponent() *NotCollisionComponent
GetNotCollisionComponent implements the NotCollisionable interface
type NotCollisionable ¶
type NotCollisionable interface {
GetNotCollisionComponent() *NotCollisionComponent
}
NotCollisionable is an interface used to flag an entity as not in the CollisionSystem even if it has the proper components
type NotMouseComponent ¶
type NotMouseComponent struct{}
NotMouseComponent is used to flag an entity as not in the MouseSystem even if it has the proper components
func (*NotMouseComponent) GetNotMouseComponent ¶
func (n *NotMouseComponent) GetNotMouseComponent() *NotMouseComponent
GetNotMouseComponent implements the NotMouseable interface
type NotMouseable ¶
type NotMouseable interface {
GetNotMouseComponent() *NotMouseComponent
}
NotMouseable is an interface used to flag an entity as not in the MouseSystem even if it has the proper components
type NotRenderComponent ¶
type NotRenderComponent struct{}
NotRenderComponent is used to flag an entity as not in the RenderSystem even if it has the proper components
func (*NotRenderComponent) GetNotRenderComponent ¶
func (n *NotRenderComponent) GetNotRenderComponent() *NotRenderComponent
GetNotRenderComponent implements the NotRenderable interface
type NotRenderable ¶
type NotRenderable interface {
GetNotRenderComponent() *NotRenderComponent
}
NotRenderable is an interface used to flag an entity as not in the Rendersystem even if it has the proper components
type Object ¶
type Object struct { // ID is the unique ID of each object defined by Tiled ID uint32 // 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 float32 // X holds the X float64 coordinate of the object in the map Y float32 // Width is the width of the object in pixels Width float32 // Height is the height of the object in pixels Height float32 // Properties are the custom properties of the object Properties []Property // Tiles are the tiles, if any, associated with the object Tiles []*Tile // Lines are the lines, if any, associated with the object Lines []TMXLine // Ellipses are the ellipses, if any, associated with the object Ellipses []TMXCircle // Text is the text, if any, associated with the object Text []TMXText }
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 // Color is the color of the object Color 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 // Opacity is the opacity of the layer from [0,1] Opacity float32 // Visible is if the layer is visible Visible bool // Properties are the custom properties of the layer Properties []Property // Objects contains the list of (regular) Object objects Objects []*Object // DrawOrder is whether the objects are drawn according to the order of // appearance (“index”) or sorted by their y-coordinate (“topdown”). // Defaults to “topdown”. DrawOrder string }
ObjectLayer contains a list of its standard objects as well as a list of all its polyline objects
type Player ¶
type Player struct { Repeat bool // contains filtered or unexported fields }
Player holds the underlying audio data and plays/pauses/stops/rewinds/seeks it.
func LoadedPlayer ¶
LoadedPlayer retrieves the *audio.Player created from the URL
func (*Player) Close ¶
Close removes the player from the audio system's players, which are currently playing players. it then finalizes and frees the data from the player. Do not use a player after it has been closed
func (*Player) Rewind ¶
Rewind rewinds the current position to the start.
Rewind returns error when seeking the source stream returns error.
func (*Player) Seek ¶
Seek seeks the position with the given offset.
Seek returns error when seeking the source stream returns error.
type Property ¶
type Property struct {
Name, Type, Value string
}
Property is any custom property. The Type corresponds to the type (int, float, etc) stored in the Value as a string
type Rectangle ¶
Rectangle is a basic rectangular form; the dimensions are controlled via the `SpaceComponent`.
func (Rectangle) Close ¶
func (Rectangle) Close()
Close does nothing, because there's no Texture on the GPU. This implements the Drawable interface.
func (Rectangle) Texture ¶
Texture always returns nil. Rectangle is drawable without a Texture. This implements the Drawable interface.
type RenderBuffer ¶
type RenderBuffer struct {
// contains filtered or unexported fields
}
func CreateRenderBuffer ¶
func CreateRenderBuffer(width, height int) *RenderBuffer
func (*RenderBuffer) Bind ¶
func (rb *RenderBuffer) Bind(attachment int)
func (*RenderBuffer) Destroy ¶
func (rb *RenderBuffer) Destroy()
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 SpaceComponent of the entity // is larger than the texture itself, after applying scale. Defaults to NoRepeat // which allows the texture to draw entirely without regard to th SpaceComponent // Do not set to anything other than NoRepeat for textures in a sprite sheet. // This does not yet work with sprite sheets. Repeat TextureRepeating // Buffer represents the buffer object itself // Avoid using it unless your are writing a custom shader Buffer *gl.Buffer // BufferContent contains the buffer data // Avoid using it unless your are writing a custom shader BufferContent []float32 // StartZIndex defines the initial Z-Index. Z-Index defines the order which the content is drawn to the // screen. Higher z-indices are drawn on top of lower ones. Beware that you must use `SetZIndex` function to change // the Z-Index. StartZIndex float32 // contains filtered or unexported fields }
RenderComponent is the component needed to render an entity.
func (*RenderComponent) GetRenderComponent ¶
func (c *RenderComponent) GetRenderComponent() *RenderComponent
GetRenderComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
func (*RenderComponent) SetMagFilter ¶
func (r *RenderComponent) SetMagFilter(z ZoomFilter)
SetMagFilter sets the ZoomFilter used for magnifying the RenderComponent
func (*RenderComponent) SetMinFilter ¶
func (r *RenderComponent) SetMinFilter(z ZoomFilter)
SetMinFilter sets the ZoomFilter used for minimizing the RenderComponent
func (*RenderComponent) SetShader ¶
func (r *RenderComponent) SetShader(s Shader)
SetShader sets the shader used by the RenderComponent.
func (*RenderComponent) SetZIndex ¶
func (r *RenderComponent) SetZIndex(index float32)
SetZIndex sets the order that the RenderComponent is drawn to the screen. Higher z-indices are drawn on top of lower ones if they overlap.
func (*RenderComponent) Shader ¶
func (r *RenderComponent) Shader() Shader
Shader gets the shader used by the RenderComponent.
type RenderFace ¶
type RenderFace interface {
GetRenderComponent() *RenderComponent
}
RenderFace allows typesafe access to an anonymous RenderComponent
type RenderSystem ¶
type RenderSystem struct {
// contains filtered or unexported fields
}
RenderSystem is the system that draws entities on the OpenGL surface. It requires a CameraSystem to work. If a CameraSystem is not in the World when you add RenderSystem one is automatically added to the world.
func (*RenderSystem) Add ¶
func (rs *RenderSystem) Add(basic *ecs.BasicEntity, render *RenderComponent, space *SpaceComponent)
Add adds an entity to the RenderSystem. The entity needs a basic, render, and space component to be added to the system.
func (*RenderSystem) AddByInterface ¶
func (rs *RenderSystem) AddByInterface(i ecs.Identifier)
AddByInterface adds any Renderable to the render system. Any Entity containing a BasicEntity,RenderComponent, and SpaceComponent anonymously does this automatically
func (*RenderSystem) EntityExists ¶
func (rs *RenderSystem) EntityExists(basic *ecs.BasicEntity) int
EntityExists looks if the entity is already into the System's entities. It will return the index >= 0 of the object into de rs.entities or -1 if it could not be found.
func (*RenderSystem) New ¶
func (rs *RenderSystem) New(w *ecs.World)
New initializes the RenderSystem
func (*RenderSystem) Priority ¶
func (*RenderSystem) Priority() int
Priority implements the ecs.Prioritizer interface.
func (*RenderSystem) Remove ¶
func (rs *RenderSystem) Remove(basic ecs.BasicEntity)
Remove removes an entity from the RenderSystem
func (*RenderSystem) Update ¶
func (rs *RenderSystem) Update(dt float32)
Update draws the entities in the RenderSystem to the OpenGL Surface.
type RenderTexture ¶
type RenderTexture struct {
// contains filtered or unexported fields
}
func CreateRenderTexture ¶
func CreateRenderTexture(width, height int, depthBuffer bool) *RenderTexture
func (*RenderTexture) Bind ¶
func (t *RenderTexture) Bind()
func (*RenderTexture) Close ¶
func (t *RenderTexture) Close()
func (*RenderTexture) Height ¶
func (t *RenderTexture) Height() float32
Height returns the height of the texture.
func (*RenderTexture) Texture ¶
func (t *RenderTexture) Texture() *gl.Texture
Texture returns the OpenGL ID of the Texture.
func (*RenderTexture) View ¶
func (t *RenderTexture) View() (float32, float32, float32, float32)
View returns the viewport properties of the Texture. The order is Min.X, Min.Y, Max.X, Max.Y.
func (*RenderTexture) Width ¶
func (t *RenderTexture) Width() float32
Width returns the width of the texture.
type Renderable ¶
type Renderable interface { BasicFace RenderFace SpaceFace }
Renderable is the required interface for the RenderSystem.AddByInterface method
type Shader ¶
type Shader interface { Setup(*ecs.World) error Pre() Draw(*RenderComponent, *SpaceComponent) Post() SetCamera(*CameraSystem) }
Shader when implemented can be used in the RenderSystem as an OpenGl Shader.
Setup holds the actual OpenGL shader data, and prepares any matrices and OpenGL calls for use.
Pre is called just before the Draw step.
Draw is the Draw step.
Post is called just after the Draw step.
type Shape ¶
Shape is a shape used for a SpaceComponent's hitboxes. It is composed of Lines that make up the polygon's shape or an ellipse which makes up an ellpitical shape. N is the number of lines used to approximate the ellpse; N defaults to 25.
func (*Shape) PolygonEllipse ¶
func (s *Shape) PolygonEllipse()
PolygonEllipse approximates the Ellipse as an N-sided polygon, determined by the shape's N value. If N is 0, it defaults to 25.
type SpaceComponent ¶
type SpaceComponent struct { Position engo.Point Width float32 Height float32 Rotation float32 // angle in degrees for the rotation to apply clockwise. // contains filtered or unexported fields }
SpaceComponent keeps track of the position, size, and rotation of entities.
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) AddShape ¶
func (sc *SpaceComponent) AddShape(shape Shape)
AddShape adds a shape to the SpaceComponent for use as a hitbox. A SpaceComponent can have any number of shapes attached to it. The shapes are made up of a []engo.Line, with each line defining a face of the shape. The coordinates are such that (0,0) is the upper left corner of the SpaceComponent. If no shapes are added, the SpaceComponent is treated as an AABB.
func (*SpaceComponent) Center ¶
func (sc *SpaceComponent) Center() engo.Point
Center gets the center position of the space component 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 shape defined by this `SpaceComponent`. If it's on the border, it is considered "not within". If there is no shape defined, then this uses a rectangular area defined by the Width/Height of the SpaceComponent instead.
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.
func (*SpaceComponent) GetSpaceComponent ¶
func (c *SpaceComponent) GetSpaceComponent() *SpaceComponent
GetSpaceComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
func (SpaceComponent) Overlaps ¶
func (sc SpaceComponent) Overlaps(other SpaceComponent, thisTolerance, otherTolerance engo.Point) (bool, engo.Point)
Overlaps tells whether the two given space components overlap with the given tolerance. Uses hitboxes if available, then tries AABB. Algorithm used is the [Separation of Axis](http://www.dyn4j.org/2010/01/sat)
func (*SpaceComponent) SetCenter ¶
func (sc *SpaceComponent) SetCenter(p engo.Point)
SetCenter 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)
type SpaceFace ¶
type SpaceFace interface {
GetSpaceComponent() *SpaceComponent
}
SpaceFace allows typesafe access to an anonymous SpaceComponent
type SpriteRegion ¶
SpriteRegion holds the position data for each sprite on the sheet
type Spritesheet ¶
type Spritesheet 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 LoadedSpritesheet ¶
func LoadedSpritesheet(url string) (*Spritesheet, error)
LoadedSpritesheet returns a Spritesheet that has already been created by New*
func NewAsymmetricSpritesheetFromFile ¶
func NewAsymmetricSpritesheetFromFile(textureName string, spriteRegions []SpriteRegion) *Spritesheet
NewAsymmetricSpritesheetFromFile creates a new AsymmetricSpriteSheet from a file name. The data provided is the location and size of the sprites
func NewAsymmetricSpritesheetFromTexture ¶
func NewAsymmetricSpritesheetFromTexture(tr *TextureResource, spriteRegions []SpriteRegion) *Spritesheet
NewAsymmetricSpritesheetFromTexture creates a new AsymmetricSpriteSheet from a TextureResource. The data provided is the location and size of the sprites
func NewSpritesheetFromFile ¶
func NewSpritesheetFromFile(textureName string, cellWidth, cellHeight int) *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, cellWidth, cellHeight int) *Spritesheet
NewSpritesheetFromTexture creates a new spritesheet from a texture resource.
func NewSpritesheetWithBorderFromFile ¶
func NewSpritesheetWithBorderFromFile(textureName string, cellWidth, cellHeight, borderWidth, borderHeight int) *Spritesheet
NewSpritesheetWithBorderFromFile creates a new spritesheet from a file This sheet has sprites of a uniform width and height, but also have borders around each sprite to prevent bleeding over
func NewSpritesheetWithBorderFromTexture ¶
func NewSpritesheetWithBorderFromTexture(tr *TextureResource, cellWidth, cellHeight, borderWidth, borderHeight int) *Spritesheet
NewSpritesheetWithBorderFromTexture creates a new spritesheet from a texture resource. This sheet has sprites of a uniform width and height, but also have borders around each sprite to prevent bleeding over
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
CellCount returns the number of cells on the sheet
func (*Spritesheet) Cells ¶
func (s *Spritesheet) Cells() []Texture
Cells returns all the cells on the sheet
func (*Spritesheet) Drawable ¶
func (s *Spritesheet) Drawable(index int) Drawable
Drawable returns the drawable for a given index
func (*Spritesheet) Drawables ¶
func (s *Spritesheet) Drawables() []Drawable
Drawables returns all the drawables on the sheet
func (Spritesheet) Height ¶
func (s Spritesheet) Height() float32
Height is the amount of tiles on the y-axis of the spritesheet only if the sprite sheet is symmetric with no border.
func (Spritesheet) Width ¶
func (s Spritesheet) Width() float32
Width is the amount of tiles on the x-axis of the spritesheet only if the sprite sheet is symmetric with no border.
type SubTexture ¶
type SubTexture struct { Text string `xml:",chardata"` // Name is the location of the subtexture before it was packed, Used as the url in the image loader Name string `xml:"name,attr"` // X coordinate of the subtexture in reference to the main image X float32 `xml:"x,attr"` // Y coordinate of the subtexture in reference to the main image Y float32 `xml:"y,attr"` // Width of the subtexture in reference to the main image Width float32 `xml:"width,attr"` // Height of the subtexture in reference to the main image Height float32 `xml:"height,attr"` }
SubTexture represents a texture from a region in the TextureAtlas
type TMXCircle ¶
type TMXCircle struct {
X, Y, Width, Height float32
}
TMXCircle is a circle from the tmx map TODO: create a tile instead using the Shape (maybe a render component?)
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 TMXText ¶
type TMXText struct { Bold bool Color string FontFamily string Halign string Italic bool Kerning bool Size float32 Strikeout bool Underline bool Valign string WordWrap bool CharData string }
TMXText is text associated with a Tiled Map. It should contain all the information needed to render text. TODO: create a tile instead and have the text rendered as a texture
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`.
func (Text) Close ¶
func (t Text) Close()
Close does nothing because the Text is generated from a FontAtlas. There is no underlying texture to close. This implements the common.Drawable interface.
func (Text) Height ¶
Height returns the height the Text generated from a FontAtlas. This implements the common.Drawable interface.
func (Text) Texture ¶
Texture returns nil because the Text is generated from a FontAtlas. This implements the common.Drawable interface.
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 TextureAtlas ¶
type TextureAtlas struct { XMLName xml.Name `xml:"TextureAtlas"` Text string `xml:",chardata"` // ImagePath is the path of the main image all the textures will be derived from ImagePath string `xml:"imagePath,attr"` // SubTextures is a slice of SubTextures SubTextures []SubTexture `xml:"SubTexture"` }
TextureAtlas is a collection of small textures grouped into a big image
type TextureAtlasResource ¶
type TextureAtlasResource struct { // Atlas is the TextureAtlas filled with data from the parsed XML file Atlas *TextureAtlas // contains filtered or unexported fields }
TextureAtlasResource contains reference to a loaded TextureAtlas and the texture of the main image
func (TextureAtlasResource) URL ¶
func (r TextureAtlasResource) URL() string
URL retrieves the url to the .xml file
type TexturePack ¶
type TextureRepeating ¶
type TextureRepeating uint8
TextureRepeating is the method used to repeat a texture in OpenGL.
const ( // NoRepeat does not repeat the texture. NoRepeat TextureRepeating = iota // ClampToEdge stretches the texture to the edge of the viewport. ClampToEdge // ClampToBorder stretches the texture to the border of the viewpport. ClampToBorder // Repeat repeats the texture until the border of the viewport. Repeat // MirroredRepeat repeats a mirror image of the texture until the border of the viewport. MirroredRepeat )
type TextureResource ¶
type TextureResource struct { Texture *gl.Texture Width float32 Height float32 Viewport *engo.AABB // contains filtered or unexported fields }
TextureResource is the resource used by the RenderSystem. It uses .jpg, .gif, and .png images
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
URL is the file path of the TextureResource
type Tile ¶
type Tile struct { engo.Point Image *Texture Drawables []Drawable Animation *Animation // Rotation of the Tile in degrees Rotation float32 }
Tile represents a tile in the TMX map.
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 // Opacity is the opacity of the layer from [0,1] Opacity float32 // Visible is if the layer is visible Visible bool // X is the x position of the tile layer X float32 // Y is the y position of the tile layer Y float32 // XOffset is the x-offset of the tile layer OffSetX float32 // YOffset is the y-offset of the tile layer OffSetY float32 // Properties are the custom properties of the layer Properties []Property }
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. The dimensions are controlled by the SpaceComponent.
func (Triangle) Close ¶
func (Triangle) Close()
Close does nothing, because there's no Texture on the GPU. This implements the Drawable interface.
func (Triangle) Texture ¶
Texture always returns nil. Triangle is drawable without a Texture. This implements the Drawable interface.
type TriangleType ¶
type TriangleType uint8
TriangleType is the type of triangle: Right or Isosceles.
const ( // TriangleIsosceles indicates a Triangle where two sides have equal length TriangleIsosceles TriangleType = iota // TriangleRight 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
Error implements the error interface.
type ZoomFilter ¶
type ZoomFilter uint8
ZoomFilter is a filter used when zooming in or out of a texture.
const ( // FilterNearest is a simple nearest neighbor algorithm FilterNearest ZoomFilter = iota // FilterLinear is a bilinear interpolation algorithm FilterLinear )
Source Files ¶
- animation.go
- audio.go
- audio_filetype.go
- audio_player.go
- camera.go
- collision.go
- doc.go
- font.go
- font_filetype.go
- fps.go
- interfaces.go
- level.go
- mouse.go
- render.go
- render_filetype.go
- render_framebuffer.go
- render_notjs.go
- render_shaders.go
- render_shaders_blendmap.go
- render_shaders_default.go
- render_shaders_shapes.go
- render_shaders_text.go
- render_shapes.go
- spritesheet.go
- texture_atlas.go
- tmx_filetype.go
- tmx_level.go
- utils.go
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
decode/convert
Package convert resamples and converts audio data
|
Package convert resamples and converts audio data |
decode/vorbis
Package vorbis provides Ogg/Vorbis decoder.
|
Package vorbis provides Ogg/Vorbis decoder. |
decode/wav
Package wav provides WAV (RIFF) decoder.
|
Package wav provides WAV (RIFF) decoder. |