common

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2018 License: MIT Imports: 34 Imported by: 0

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

View Source
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
)
View Source
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
)
View Source
const MouseSystemPriority = 100

MouseSystemPriority is the priority of the MouseSystem

View Source
const (
	// RenderSystemPriority is the priority of the RenderSystem
	RenderSystemPriority = -1000
)

Variables

View Source
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
)
View Source
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}
)
View Source
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.

View Source
var UnicodeCap = 200

UnicodeCap is the amount of unicode characters the fonts will be able to use, starting from index 0.

Functions

func GetMasterVolume

func GetMasterVolume() float64

GetMasterVolume gets the master volume of the audio system.

func ImageToNRGBA

func ImageToNRGBA(img image.Image, width, height int) *image.NRGBA

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

func IsIntersecting(rect1 engo.AABB, rect2 engo.AABB) bool

IsIntersecting tells if two engo.AABBs intersect.

func LoadShader

func LoadShader(vertSrc, fragSrc string) (*gl.Program, error)

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

func MinimumTranslation(rect1 engo.AABB, rect2 engo.AABB) engo.Point

MinimumTranslation tells how much an entity has to move to no longer overlap another entity.

func SetBackground

func SetBackground(c color.Color)

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

func UploadTexture(img Image) *gl.Texture

UploadTexture sends the image to the GPU, to be kept in GPU RAM

Types

type Animation

type Animation struct {
	Name   string
	Frames []int
	Loop   bool
}

Animation represents properties of an animation.

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 {
	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) New

func (a *AudioSystem) New(w *ecs.World)

New is called when the AudioSystem is added to the world.

func (*AudioSystem) Remove

func (a *AudioSystem) Remove(basic ecs.BasicEntity)

Remove removes an entity from the AudioSystem

func (*AudioSystem) Update

func (a *AudioSystem) Update(dt float32)

Update is called once per frame, and updates/plays the players in the AudioSystem

type Audioable

type Audioable interface {
	BasicFace
	AudioFace
}

Audioable is the required interface for the AudioSystem.AddByInterface method

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 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.

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

type Circle struct {
	BorderWidth float32
	BorderColor color.Color
}

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) Height

func (Circle) Height() float32

Height always returns 0. This implements the Drawable interface.

func (Circle) Texture

func (Circle) Texture() *gl.Texture

Texture always returns nil. Circle is drawable without a Texture. This implements the Drawable interface.

func (Circle) View

func (Circle) View() (float32, float32, float32, float32)

View always returns 0, 0, 1, 1. This implements the Drawable interface.

func (Circle) Width

func (Circle) Width() float32

Width always returns 0. 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

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 Cursor

type Cursor uint8

Cursor is a reference to a GLFW-cursor - to be used with the `SetCursor` method.

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

type EdgeScroller struct {
	ScrollSpeed float32
	EdgeMargin  float32
}

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 {
	*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) Create

func (f *Font) Create() error

Create is for loading fonts from the disk, given a location

func (*Font) CreatePreloaded

func (f *Font) CreatePreloaded() error

CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload

func (*Font) Render

func (f *Font) Render(text string) Texture

Render returns a Texture in the Font based on the input string.

func (*Font) RenderNRGBA

func (f *Font) RenderNRGBA(text string) *image.NRGBA

RenderNRGBA returns an *image.NRGBA in the Font based on the input string.

func (*Font) TextDimensions

func (f *Font) TextDimensions(text string) (int, int, int)

TextDimensions returns the total width, total height and total line size of the input string written out in the Font.

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

type FontResource struct {
	Font *truetype.Font
	// contains filtered or unexported fields
}

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

Error implements the error interface.

type Image

type Image interface {
	Data() interface{}
	Width() int
	Height() int
}

Image holds data and properties of an .jpg, .gif, or .png file

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

func (*Level) Bounds

func (l *Level) Bounds() engo.AABB

Bounds returns the level boundaries as an engo.AABB object

func (*Level) GetTile

func (l *Level) GetTile(pt engo.Point) *Tile

GetTile returns a *Tile at the given point (in space / render coordinates).

func (*Level) Height

func (l *Level) Height() int

Height returns the integer height of the level

func (*Level) Width

func (l *Level) Width() int

Width returns the integer width of the 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 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

func LoadedPlayer(url string) (*Player, error)

LoadedPlayer retrieves the *audio.Player created from the URL

func (*Player) Close

func (p *Player) Close() error

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.

func (*Player) Current

func (p *Player) Current() time.Duration

Current returns the current position.

func (*Player) GetVolume

func (p *Player) GetVolume() float64

GetVolume gets the Player's volume

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

IsPlaying returns boolean indicating whether the player is playing.

func (*Player) Pause

func (p *Player) Pause()

Pause pauses the playing.

func (*Player) Play

func (p *Player) Play()

Play plays the player's audio.

func (*Player) Rewind

func (p *Player) Rewind() error

Rewind rewinds the current position to the start.

Rewind returns error when seeking the source stream returns error.

func (*Player) Seek

func (p *Player) Seek(offset time.Duration) error

Seek seeks the position with the given offset.

Seek returns error when seeking the source stream returns error.

func (*Player) SetVolume

func (p *Player) SetVolume(volume float64)

SetVolume sets the Player's volume volume can only be set from 0 to 1

func (*Player) URL

func (p *Player) URL() string

URL implements the engo.Resource interface. It retrieves the player's source url.

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

type Rectangle struct {
	BorderWidth float32
	BorderColor color.Color
}

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) Height

func (Rectangle) Height() float32

Height always returns 0. This implements the Drawable interface.

func (Rectangle) Texture

func (Rectangle) Texture() *gl.Texture

Texture always returns nil. Rectangle is drawable without a Texture. This implements the Drawable interface.

func (Rectangle) View

func (Rectangle) View() (float32, float32, float32, float32)

View always returns 0, 0, 1, 1. This implements the Drawable interface.

func (Rectangle) Width

func (Rectangle) Width() float32

Width always returns 0. 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) 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 *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 {
	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()
}

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 SpaceComponent

type SpaceComponent struct {
	Position engo.Point
	Width    float32
	Height   float32
	Rotation float32 // angle in degrees for the rotation to apply clockwise.
}

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) 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 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.

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) 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

type SpriteRegion struct {
	Position      engo.Point
	Width, Height int
}

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 TMXLine

type TMXLine struct {
	Lines []*engo.Line
	Type  string
}

TMXLine is a line from the tmx map TODO: create a tile or render coponent instead?

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

func (TMXResource) URL

func (r TMXResource) URL() string

URL retrieves the url to the .tmx file

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

func (t Text) Height() float32

Height returns the height the Text generated from a FontAtlas. This implements the common.Drawable interface.

func (Text) Texture

func (t Text) Texture() *gl.Texture

Texture returns nil because the Text is generated from a FontAtlas. This implements the common.Drawable interface.

func (Text) View

func (t Text) View() (float32, float32, float32, float32)

View returns 0, 0, 1, 1 because the Text is generated from a FontAtlas. This implements the common.Drawable interface.

func (Text) Width

func (t Text) Width() float32

Width returns the width of the Text 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

func LoadedSprite(url string) (*Texture, error)

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

func NewTextureSingle(img Image) Texture

NewTextureSingle sends the image to the GPU and returns a `Texture` with a viewport for single-sprite images

func (Texture) Close

func (t Texture) Close()

Close removes the Texture data from the GPU.

func (Texture) Height

func (t Texture) Height() float32

Height returns the height of the texture.

func (Texture) Texture

func (t Texture) Texture() *gl.Texture

Texture returns the OpenGL ID of the Texture.

func (Texture) View

func (t Texture) 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 (Texture) Width

func (t Texture) Width() float32

Width returns the width of the texture.

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

type Tile struct {
	engo.Point
	Image *Texture
}

Tile represents a tile in the TMX map.

func (*Tile) Close

func (t *Tile) Close()

Close deletes the stored texture of a tile

func (*Tile) Height

func (t *Tile) Height() float32

Height returns the integer height of the tile

func (*Tile) Texture

func (t *Tile) Texture() *gl.Texture

Texture returns the tile's Image texture

func (*Tile) View

func (t *Tile) View() (float32, float32, float32, float32)

View returns the tile's viewport's min and max X & Y

func (*Tile) Width

func (t *Tile) Width() float32

Width returns the integer width of the tile

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) Height

func (Triangle) Height() float32

Height always returns 0. This implements the Drawable interface.

func (Triangle) Texture

func (Triangle) Texture() *gl.Texture

Texture always returns nil. Triangle is drawable without a Texture. This implements the Drawable interface.

func (Triangle) View

func (Triangle) View() (float32, float32, float32, float32)

View always returns 0, 0, 1, 1. This implements the Drawable interface.

func (Triangle) Width

func (Triangle) Width() float32

Width always returns 0. 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

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
)

Directories

Path Synopsis
internal
decode/convert
package convert resamples and converts audio data
package convert resamples and converts audio data
decode/mp3
Package mp3 provides MP3 decoder.
Package mp3 provides MP3 decoder.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL