orbengine

package module
v0.0.0-...-a7bb707 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2015 License: MIT Imports: 5 Imported by: 0

README

Orbengine

SDL2 engine for easy 2D rendering stuff. Built for use with Orbiting.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingComponents = errors.New("missing required components")
	ErrEntityIDExists    = errors.New("entity ID already in use")
)

Engine errors.

Functions

This section is empty.

Types

type Actionable

type Actionable interface {
	Identifier
	Action()
}

Actionable is the interface for entity actions. TODO: this is where we can animate entities. Check how this will need to be implemented.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the central struct from which the entire engine can be controlled.

func Build

func Build() (*Controller, error)

Build creates a Controller struct. NOTE: locks the OS thread. Make sure to call all Controller.func from the exact same goroutine, otherwise the SDL context may crash!

func (*Controller) AddEntity

func (c *Controller) AddEntity(entity Identifier) error

AddEntity will add the entity to the controller. If the entity does not match any orbengine interface, an error is returned.

func (*Controller) Destroy

func (c *Controller) Destroy()

Destroy the controller object.

func (*Controller) Iterate

func (c *Controller) Iterate()

Iterate advances the controller by one step.

TODO make engine handle game loop... :P

func (*Controller) RegisterKey

func (c *Controller) RegisterKey(key string, onPress, onRelease func()) error

RegisterKey allows entities to receive key presses by registering the functions to execute when a key is either pressed or released.

type Drawable

type Drawable interface {
	Placeable
	Texture(texture *sdl.Texture)
}

Drawable is the interface an entity must fulfill to be drawable.

type Identifier

type Identifier interface {
	Identification() string
}

Identifier is the base interface all entites must match. It allows the engine to reference entities as specified by the application.

type Placeable

type Placeable interface {
	Identifier
	Position() *sdl.Point
	Offset() *sdl.Point // Offset is center of orientation offset from position. FIXME use and apply
	Scale() int
	Width() int
	Height() int
	Rotation() float64
	Layer() int
	Redraw() bool // TODO this should be somewhere else, but for now...
}

Placeable is the interface used to determine where to place an object.

type Renderable

type Renderable interface {
	Placeable
	Render(renderer *Renderer)
}

Renderable is an alternative interface for Drawable for manually drawing entities.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer wraps the sdl.Renderer to control what methods are available for drawing interfaces.

func (*Renderer) FillRect

func (w *Renderer) FillRect(rect *sdl.Rect)

func (*Renderer) GetRendererOutputSize

func (w *Renderer) GetRendererOutputSize() (int, int, error)

func (*Renderer) SetDrawColor

func (w *Renderer) SetDrawColor(r, g, b, a uint8)

type Unit

type Unit struct {
	// contains filtered or unexported fields
}

Unit is an abstraction for designating number values.

func CreateUnit

func CreateUnit(aspect float32) *Unit

CreateUnit creates a new unit for converting arbitrary measurement units to engine units.

Jump to

Keyboard shortcuts

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