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