Documentation
¶
Index ¶
- Constants
- Variables
- func ImageToNRGBA(img image.Image, width, height int) *image.NRGBA
- func LoadShader(vertSrc, fragSrc string) (*gl.Program, error)
- 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 (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 CameraAxis
- type CameraMessage
- type CameraSystem
- func (cam *CameraSystem) Angle() float32
- func (cam *CameraSystem) FollowEntity(basic *ecs.BasicEntity, space *physics.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 ComplexTriangles
- type Drawable
- type EdgeScroller
- type EntityScroller
- type Font
- type FontAtlas
- type FontResource
- type FragmentShaderCompilationError
- type Image
- type ImageLayer
- type ImageObject
- type KeyboardScroller
- type Level
- type MouseRotator
- type MouseZoomer
- type NewCameraMessage
- type NotAnimationComponent
- type NotAnimationable
- type NotRenderComponent
- type NotRenderable
- type Object
- type ObjectLayer
- type Property
- type Rectangle
- type RenderComponent
- func (c *RenderComponent) GetRenderComponent() *RenderComponent
- func (r *RenderComponent) IsHUDShader() bool
- func (r *RenderComponent) SetMagFilter(z ZoomFilter)
- func (r *RenderComponent) SetMinFilter(z ZoomFilter)
- func (r *RenderComponent) SetShader(s Shader)
- func (r *RenderComponent) SetZIndex(index float32)
- type RenderFace
- type RenderSystem
- func (rs *RenderSystem) Add(basic *ecs.BasicEntity, render *RenderComponent, space *physics.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 Renderable
- type Shader
- type SpriteRegion
- type Spritesheet
- 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 TMXCircle
- type TMXLine
- type TMXResource
- type TMXText
- type Text
- type Texture
- 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 (
// 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 ( // 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} )
var UnicodeCap = 200
UnicodeCap is the amount of unicode characters the fonts will be able to use, starting from index 0.
Functions ¶
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 ¶
SetBackground sets the OpenGL ClearColor to the provided color.
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) 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 { basic.BasicFace AnimationFace RenderFace }
Animationable is the required interface for AnimationSystem.AddByInterface method
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 *physics.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.
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 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 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 EntityScroller ¶
type EntityScroller struct { *physics.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 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 (*Font) CreatePreloaded ¶
CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
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 // 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 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 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 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 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 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 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 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 // 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) IsHUDShader ¶
func (r *RenderComponent) IsHUDShader() bool
IsHUDShader returns true if the shader is an HUD shader and acts like it under zooming and panning
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.
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 *physics.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 Renderable ¶
type Renderable interface { basic.BasicFace RenderFace physics.SpaceFace }
Renderable is the required interface for the RenderSystem.AddByInterface method
type Shader ¶
type Shader interface { Setup(*ecs.World) error Pre() Draw(*RenderComponent, *physics.SpaceComponent) Post() }
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 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 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 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 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 // 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 ¶
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 )