engine

package
v0.0.0-...-e01bfcd Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2014 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Taken from https://github.com/juj/RectangleBinPack.

Index

Constants

View Source
const (
	RadianConst = math.Pi / 180
	DegreeConst = 180 / math.Pi
	MouseTag    = "Mouse"
)
View Source
const (
	PI     = math.Pi
	PI_180 = math.Pi / 180
	PI_360 = math.Pi / 360
)
View Source
const (
	Nearest              = Filter(gl.NEAREST)
	Linear               = Filter(gl.LINEAR)
	MipMapLinearNearest  = Filter(gl.LINEAR_MIPMAP_NEAREST)
	MipMapLinearLinear   = Filter(gl.LINEAR_MIPMAP_LINEAR)
	MipMapNearestLinear  = Filter(gl.NEAREST_MIPMAP_LINEAR)
	MipMapNearestNearest = Filter(gl.NEAREST_MIPMAP_NEAREST)

	WrapS = WrapType(gl.TEXTURE_WRAP_S)
	WrapR = WrapType(gl.TEXTURE_WRAP_R)
	WrapT = WrapType(gl.TEXTURE_WRAP_T)

	ClampToEdge    = Wrap(gl.CLAMP_TO_EDGE)
	ClampToBorder  = Wrap(gl.CLAMP_TO_BORDER)
	MirroredRepeat = Wrap(gl.MIRRORED_REPEAT)
	Repeat         = Wrap(gl.REPEAT)
)
View Source
const (
	AlignLeft   = Align(1)
	AlignCenter = Align(2)
	AlignRight  = Align(4)

	AlignTopLeft   = Align(8 | AlignLeft)
	AlignTopCenter = Align(8 | AlignCenter)
	AlignTopRight  = Align(8 | AlignRight)

	AlignBottomLeft   = Align(16 | AlignLeft)
	AlignBottomCenter = Align(16 | AlignCenter)
	AlignBottomRight  = Align(16 | AlignRight)
)

Variables

View Source
var (
	Color_White       = Color{1, 1, 1, 1}
	Color_Black       = Color{0, 0, 0, 1}
	Color_Red         = Color{1, 0, 0, 1}
	Color_Green       = Color{0, 1, 0, 1}
	Color_Blue        = Color{0, 0, 1, 1}
	Color_Transparent = Color{1, 1, 1, 0}
)
View Source
var (
	Inf = vect.Float(math.Inf(1))

	Space *chipmunk.Space = nil

	CorrectWrongPhysics = true
	EnablePhysics       = true
	Debug               = false
	InternalFPS         = float64(100)

	BehaviorTicks = 5

	Width  = 1280
	Height = 720
)
View Source
var (
	Zero     = Vector{0, 0, 0}
	Up       = Vector{0, 1, 0}
	Down     = Vector{0, -1, 0}
	Left     = Vector{-1, 0, 0}
	Right    = Vector{1, 0, 0}
	Forward  = Vector{0, 0, 1}
	Backward = Vector{0, 0, -1}
	One      = Vector{1, 1, 1}
	MinusOne = Vector{-1, -1, -1}
)
View Source
var (
	CustomColorModels = make(map[color.Model]*GLColorModel)
)
View Source
var Padding = 1
View Source
var (
	ResourceManager = &Resources{make(map[ResID]Resource)}
)
View Source
var TextureShader gl.Program

Functions

func Abs

func Abs(val float32) float32

func AddScene

func AddScene(scene Scene)

func AtlasFromSheet

func AtlasFromSheet(path string, width, height, frames int) (atlas *ManagedAtlas, groupID ID, err error)
func NewRGBA(r image.Rectangle) (*image.RGBA, *MemHandle) {
	w, h := r.Dx(), r.Dy()
	memHandle := Allocate(4 * w * h)
	buf := memHandle.Bytes()
	ResourceManager.Add(memHandle)
	return &image.RGBA{buf, 4 * w, r}, memHandle
}

func ColorModelToGLTypes

func ColorModelToGLTypes(model color.Model) (internalFormat int, typ gl.GLenum, format gl.GLenum, target gl.GLenum, err error)

func DeltaTime

func DeltaTime() float64

func DrawSprite

func DrawSprite(tex *Texture, uv UV, position Vector, scale Vector, rotation float32, aling Align, color Color)

func DrawSprites

func DrawSprites(tex *Texture, uvs []UV, positions []Vector, scales []Vector, rotations []float32, alings []Align, colors []Color)

func FindOptimalSize

func FindOptimalSize(tries int, rects ...image.Rectangle) (w, h int, err error)

This needs to be smarter, but it does work great for images like fonts

func FindOptimalSizeFast

func FindOptimalSizeFast(totalSize int64) (w, h int)

func FindSDF

func FindSDF(img image.Image, x, y, maxRadius int) int

func FindSDFAlpha

func FindSDFAlpha(img *image.Alpha, x, y, maxRadius int) int

func GameTime

func GameTime() time.Time

func InsideScreen

func InsideScreen(ratio float32, position Vector, scale Vector) bool

func LerpAngle

func LerpAngle(from, to float32, t float32) float32

func Lerpf

func Lerpf(from, to float32, t float32) float32

func LoadGIF

func LoadGIF(path string) (imgs []image.Image, err error)

func LoadImage

func LoadImage(path string) (img image.Image, err error)

func LoadImageQuiet

func LoadImageQuiet(path string) (img image.Image)

func LoadScene

func LoadScene(scene Scene)

func MainLoop

func MainLoop() bool

func NextPowerOfTwo

func NextPowerOfTwo(x uint64) uint64

func PanicPath

func PanicPath() string

func RenderAtlas

func RenderAtlas(a Atlas)

func Roundf

func Roundf(val float32, places int) float32

func Run

func Run()

func SetTitle

func SetTitle(title string)

func StartEngine

func StartEngine()

func Terminate

func Terminate()

func Title

func Title() string

Types

type Align

type Align byte

func (Align) Vector

func (typ Align) Vector() Vector

type AnimatedUV

type AnimatedUV []UV

func AnimatedGroupUVs

func AnimatedGroupUVs(a Atlas, groups ...ID) (AnimatedUV, map[ID][2]int)

func AnimatedUVs

func AnimatedUVs(a Atlas, ids ...ID) AnimatedUV

func IndexGroupUV

func IndexGroupUV(a Atlas, group ID) AnimatedUV

type Arbiter

type Arbiter struct {
	*chipmunk.Arbiter

	Swapped bool
	// contains filtered or unexported fields
}

func (*Arbiter) GameObjectA

func (arbiter *Arbiter) GameObjectA() *GameObject

func (*Arbiter) GameObjectB

func (arbiter *Arbiter) GameObjectB() *GameObject

func (*Arbiter) Normal

func (arbiter *Arbiter) Normal(contact *chipmunk.Contact) Vector

func (*Arbiter) ShapeB

func (arbiter *Arbiter) ShapeB() *GameObject
func (arbiter *Arbiter) ShapeA() *chipmunk.Shape {
	if arbiter.Swapped {
		return arbiter.Arbiter.ShapeB
	}
	return arbiter.Arbiter.ShapeA
}
func (arbiter *Arbiter) ShapeB() *chipmunk.Shape {
	if arbiter.Swapped {
		return arbiter.Arbiter.ShapeA
	}
	return arbiter.Arbiter.ShapeB
}

type Atlas

type Atlas interface {
	GLTexture
	Index(id ID) image.Rectangle
	Group(id ID) []image.Rectangle
}

type BaseComponent

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

func NewComponent

func NewComponent() BaseComponent

func (*BaseComponent) Awake

func (c *BaseComponent) Awake()

func (*BaseComponent) Clone

func (c *BaseComponent) Clone()

func (*BaseComponent) Draw

func (c *BaseComponent) Draw()

func (*BaseComponent) FixedUpdate

func (c *BaseComponent) FixedUpdate()

func (*BaseComponent) GameObject

func (c *BaseComponent) GameObject() *GameObject

func (*BaseComponent) LateUpdate

func (c *BaseComponent) LateUpdate()

func (*BaseComponent) OnCollisionEnter

func (c *BaseComponent) OnCollisionEnter(arbiter Arbiter) bool

func (*BaseComponent) OnCollisionExit

func (c *BaseComponent) OnCollisionExit(arbiter Arbiter)

func (*BaseComponent) OnCollisionPostSolve

func (c *BaseComponent) OnCollisionPostSolve(arbiter Arbiter)

func (*BaseComponent) OnCollisionPreSolve

func (c *BaseComponent) OnCollisionPreSolve(arbiter Arbiter) bool

func (*BaseComponent) OnComponentAdd

func (c *BaseComponent) OnComponentAdd()

func (*BaseComponent) OnDestroy

func (c *BaseComponent) OnDestroy()

func (*BaseComponent) OnDisable

func (c *BaseComponent) OnDisable()

func (*BaseComponent) OnEnable

func (c *BaseComponent) OnEnable()

func (*BaseComponent) OnMouseEnter

func (c *BaseComponent) OnMouseEnter(arbiter Arbiter) bool

func (*BaseComponent) OnMouseExit

func (c *BaseComponent) OnMouseExit(arbiter Arbiter)

func (*BaseComponent) PostDraw

func (c *BaseComponent) PostDraw()

func (*BaseComponent) Start

func (c *BaseComponent) Start()

func (*BaseComponent) Transform

func (c *BaseComponent) Transform() *Transform

func (*BaseComponent) Update

func (c *BaseComponent) Update()

type BasicMaterial

type BasicMaterial struct {
	Program Program

	ViewMatrix, ProjMatrix, ModelMatrix, AddColor, Texture, Tiling, Offset gl.UniformLocation
	Verts, UV                                                              gl.AttribLocation
	// contains filtered or unexported fields
}
var SDFMaterial *BasicMaterial
var TextureMaterial *BasicMaterial

func NewBasicMaterial

func NewBasicMaterial(vertexShader, fragmentShader string) *BasicMaterial

func (*BasicMaterial) Begin

func (b *BasicMaterial) Begin(gobj *GameObject)

func (*BasicMaterial) End

func (b *BasicMaterial) End(gobj *GameObject)

func (*BasicMaterial) Load

func (b *BasicMaterial) Load() error

type Batch

type Batch interface {
	Add(position, scale Vector, rotation float32, uv UV) (index int)
	Update(index int, position, scale Vector, rotation float32, uv UV)
	UpdateUV(uv UV, index int)
	Remove(index int)
	Render()
}

type Camera

type Camera struct {
	BaseComponent
	Projection *Matrix
	// contains filtered or unexported fields
}

func CurrentCamera

func CurrentCamera() *Camera

func NewCamera

func NewCamera() *Camera

func (*Camera) Clear

func (c *Camera) Clear()

func (*Camera) InsideScreen

func (c *Camera) InsideScreen(ratio float32, position Vector, scale Vector) bool

Checks if box is in the screen

func (*Camera) InvertedMatrix

func (c *Camera) InvertedMatrix() Matrix

InvertedMatrix of the camera, this is needed because we will optimize it someday

func (*Camera) LateUpdate

func (c *Camera) LateUpdate()

func (*Camera) Matrix

func (c *Camera) Matrix() Matrix

Matrix of the camera, this is needed because sometimes we control the matrix

func (*Camera) MouseLocalPosition

func (c *Camera) MouseLocalPosition() Vector

Mouse local position

func (*Camera) MouseWorldPosition

func (c *Camera) MouseWorldPosition() Vector

Mouse world position

func (*Camera) Render

func (c *Camera) Render()

Forcing all the objects to render

func (*Camera) ScreenResolution

func (c *Camera) ScreenResolution() (Width, Height float32)

Screen resolution

func (*Camera) ScreenSize

func (c *Camera) ScreenSize() (Width, Height float32)

Returns Screen Size

func (*Camera) ScreenToWorld

func (c *Camera) ScreenToWorld(x, y float32) Vector

Takes a point on the screen and turns it into point on world

func (*Camera) SetSize

func (c *Camera) SetSize(size float32) error

Setting the size and also scale if sizeIsScale is true

func (*Camera) Size

func (c *Camera) Size() float32

Size of the camera screen

func (*Camera) Update

func (c *Camera) Update()

func (*Camera) UpdateResolution

func (c *Camera) UpdateResolution()

Updates the Projection

type Color

type Color struct {
	R, G, B, A float32
}

type Component

type Component interface {
	Draw()
	PostDraw()
	Update()
	FixedUpdate()
	Start()
	Awake()
	Clone()
	LateUpdate()

	OnEnable()
	OnDisable()

	OnCollisionEnter(arbiter Arbiter) bool
	OnCollisionPreSolve(arbiter Arbiter) bool
	OnCollisionPostSolve(arbiter Arbiter)
	OnCollisionExit(arbiter Arbiter)

	OnMouseEnter(arbiter Arbiter) bool
	OnMouseExit(arbiter Arbiter)

	OnComponentAdd()
	OnDestroy()
	// contains filtered or unexported methods
}

type DepthMap

type DepthMap []depthData

func (*DepthMap) Add

func (this *DepthMap) Add(depth int, object *GameObject)

func (DepthMap) Iter

func (this DepthMap) Iter(fnc func(*GameObject))

func (DepthMap) Len

func (this DepthMap) Len() int

func (DepthMap) Less

func (this DepthMap) Less(i, j int) bool

func (*DepthMap) Remove

func (this *DepthMap) Remove(depth int, object *GameObject) bool

func (DepthMap) String

func (this DepthMap) String() string

func (DepthMap) Swap

func (this DepthMap) Swap(i, j int)

type EngineColorModel

type EngineColorModel interface {
	color.Model
	Data() interface{}
}

type FPS

type FPS struct {
	BaseComponent
	FPS float64
	// contains filtered or unexported fields
}

func NewFPS

func NewFPS() *FPS

func (*FPS) SetAction

func (sp *FPS) SetAction(action func(float64))

func (*FPS) Update

func (sp *FPS) Update()

type Filter

type Filter int

type Font

type Font struct {
	*Texture
	// contains filtered or unexported fields
}

func NewFont

func NewFont(fontPath string, size float64) (*Font, error)

func NewFont2

func NewFont2(fontPath string, size float64, dpi int, readonly bool, firstRune, lastRune rune) (*Font, error)

func NewSDFFont

func NewSDFFont(fontPath string, size float64) (*Font, error)

func NewSDFFont2

func NewSDFFont2(fontPath string, size float64, sdfSize float64, scanRange int) (*Font, error)

func NewSDFFont3

func NewSDFFont3(fontPath string, size float64, dpi int, readonly bool, firstRune, lastRune rune, sdfSize float64, scanRange int) (*Font, error)

func (*Font) CheckText

func (t *Font) CheckText(s string)

func (*Font) Group

func (t *Font) Group(id ID) []image.Rectangle

func (*Font) Index

func (t *Font) Index(runei ID) image.Rectangle

func (*Font) IsSDF

func (t *Font) IsSDF() bool

func (*Font) LetterInfo

func (t *Font) LetterInfo(letter rune) *LetterInfo

func (*Font) Size

func (t *Font) Size() float64

type FuncKey

type FuncKey *func()

type FuncList

type FuncList struct {
	Functions []FuncKey
}

func NewFuncList

func NewFuncList(f func()) *FuncList

func (*FuncList) Add

func (this *FuncList) Add(fnc func()) (key FuncKey)

func (*FuncList) Remove

func (this *FuncList) Remove(key FuncKey) (deleted bool)

func (*FuncList) Run

func (this *FuncList) Run()

type GLColorModel

type GLColorModel struct {
	InternalFormat int
	Type           gl.GLenum
	Format         gl.GLenum
	Target         gl.GLenum
	PixelBytesSize int
	Model          EngineColorModel
}

type GLTexture

type GLTexture interface {
	GLTexture() gl.Texture
	Height() int
	Width() int
	PixelSize() int
	Bind()
}

type GameObject

type GameObject struct {
	Tag     string
	Physics *Physics
	Sprite  *Sprite
	// contains filtered or unexported fields
}

func NewGameObject

func NewGameObject(name string) *GameObject

func (*GameObject) AddComponent

func (g *GameObject) AddComponent(com Component) Component

func (*GameObject) AddToScene

func (g *GameObject) AddToScene()

func (*GameObject) Clone

func (g *GameObject) Clone() *GameObject

func (*GameObject) ComponentImplements

func (g *GameObject) ComponentImplements(intrfce interface{}) Component

func (*GameObject) ComponentTypeOf

func (g *GameObject) ComponentTypeOf(component Component) Component

func (*GameObject) Components

func (g *GameObject) Components() []Component

func (*GameObject) Destroy

func (g *GameObject) Destroy()

func (*GameObject) GameObject

func (c *GameObject) GameObject() *GameObject

func (*GameObject) IsActive

func (g *GameObject) IsActive() bool

func (*GameObject) IsSelfActive

func (g *GameObject) IsSelfActive() bool

func (*GameObject) IsValid

func (g *GameObject) IsValid() bool

func (*GameObject) Name

func (g *GameObject) Name() string

func (*GameObject) RemoveComponent

func (g *GameObject) RemoveComponent(com Component) bool

func (*GameObject) RemoveComponentOfType

func (g *GameObject) RemoveComponentOfType(typ reflect.Type) bool

func (*GameObject) RemoveComponentsOfType

func (g *GameObject) RemoveComponentsOfType(typ reflect.Type)

func (*GameObject) RemoveFromScene

func (g *GameObject) RemoveFromScene()

Removed object from Scene if hes in one

func (*GameObject) SetActive

func (g *GameObject) SetActive(active bool)

func (*GameObject) SetName

func (g *GameObject) SetName(name string)

func (*GameObject) Transform

func (g *GameObject) Transform() *Transform

type ID

type ID interface{}

type LetterInfo

type LetterInfo struct {
	Rect           image.Rectangle
	YOffset        float32
	XOffset        float32
	XAdvance       float32
	RelativeWidth  float32
	RelativeHeight float32
}

type ManagedAtlas

type ManagedAtlas struct {
	*Texture

	Bin *MaxRectsBin
	// contains filtered or unexported fields
}

func AtlasLoadDirectory

func AtlasLoadDirectory(path string) (*ManagedAtlas, error)

func NewManagedAtlas

func NewManagedAtlas(width, height int) *ManagedAtlas

func (*ManagedAtlas) AddImage

func (ma *ManagedAtlas) AddImage(img image.Image, id ID) error

func (*ManagedAtlas) BuildAtlas

func (ma *ManagedAtlas) BuildAtlas() error

func (*ManagedAtlas) Group

func (ma *ManagedAtlas) Group(id ID) []image.Rectangle

func (*ManagedAtlas) Index

func (ma *ManagedAtlas) Index(id ID) image.Rectangle

func (*ManagedAtlas) Indexs

func (ma *ManagedAtlas) Indexs() []ID

func (*ManagedAtlas) LoadGIF

func (atlas *ManagedAtlas) LoadGIF(path string) (err error, groupID ID)

func (*ManagedAtlas) LoadGIFID

func (atlas *ManagedAtlas) LoadGIFID(path string, groupID ID) (err error)

func (*ManagedAtlas) LoadGroup

func (atlas *ManagedAtlas) LoadGroup(path string) error

func (*ManagedAtlas) LoadGroupSheet

func (atlas *ManagedAtlas) LoadGroupSheet(path string, width, height, frames int) (err error, groupID ID)

func (*ManagedAtlas) LoadGroupSheetOffset

func (atlas *ManagedAtlas) LoadGroupSheetOffset(path string, pt image.Point, width, height, frames int) (err error, groupID ID)

func (*ManagedAtlas) LoadImage

func (ma *ManagedAtlas) LoadImage(path string) (err error, id ID)

func (*ManagedAtlas) LoadImageID

func (ma *ManagedAtlas) LoadImageID(path string, id ID) error

func (*ManagedAtlas) Release

func (atlas *ManagedAtlas) Release()

type Material

type Material interface {
	Load() error
	Begin(gobj *GameObject)
	End(gobj *GameObject)
}

type Matrix

type Matrix [16]float32

func Identity

func Identity() Matrix

func Mul

func Mul(m1, m2 Matrix) (m3 Matrix)

func NewIdentity

func NewIdentity() *Matrix

func (*Matrix) Invert

func (mA *Matrix) Invert() Matrix

func (*Matrix) Mul

func (m1 *Matrix) Mul(m2 Matrix)

func (*Matrix) MulPtr

func (m1 *Matrix) MulPtr(m2 *Matrix)

func (*Matrix) Ortho

func (mA *Matrix) Ortho(left, right, bottom, top, Znear, Zfar float32)

func (*Matrix) Ptr

func (mA *Matrix) Ptr() *float32

func (*Matrix) Reset

func (mA *Matrix) Reset()

func (*Matrix) Rotate

func (mA *Matrix) Rotate(a, x, y, z float32)

func (*Matrix) RotateX

func (mA *Matrix) RotateX(a, x float32)

func (*Matrix) RotateXYZ

func (mA *Matrix) RotateXYZ(x, y, z float32)

func (*Matrix) RotateY

func (mA *Matrix) RotateY(a, y float32)

func (*Matrix) RotateZ

func (mA *Matrix) RotateZ(a, z float32)

func (*Matrix) Scale

func (mA *Matrix) Scale(x, y, z float32)

func (*Matrix) Translate

func (mA *Matrix) Translate(x, y, z float32)

func (*Matrix) Translation

func (mA *Matrix) Translation() Vector

type MaxRectsBin

type MaxRectsBin struct {
	Width, Height int
	Padding       int
	// contains filtered or unexported fields
}

func NewBin

func NewBin(width, height, padding int) *MaxRectsBin

func (*MaxRectsBin) FindPositionForNewNodeBestShortSideFit

func (this *MaxRectsBin) FindPositionForNewNodeBestShortSideFit(width, height int) (bestNode image.Rectangle, bestShortSideFit, bestLongSideFit int)

func (*MaxRectsBin) Insert

func (this *MaxRectsBin) Insert(rect image.Rectangle) (image.Rectangle, error)

func (*MaxRectsBin) InsertArray

func (this *MaxRectsBin) InsertArray(rects []image.Rectangle) ([]image.Rectangle, error)

func (*MaxRectsBin) Occupancy

func (this *MaxRectsBin) Occupancy() float32

/ Computes the ratio of used surface area.

func (*MaxRectsBin) PruneFreeList

func (this *MaxRectsBin) PruneFreeList()

func (*MaxRectsBin) SplitFreeNode

func (this *MaxRectsBin) SplitFreeNode(freeNode, usedNode image.Rectangle) bool

func (*MaxRectsBin) String

func (this *MaxRectsBin) String() string

type MemHandle

type MemHandle struct {
	Buff []byte
}

func Allocate

func Allocate(size int) *MemHandle

func (*MemHandle) Bytes

func (m *MemHandle) Bytes() []byte

func (*MemHandle) Release

func (m *MemHandle) Release()

type Mouse

type Mouse struct {
	BaseComponent
}

func NewMouse

func NewMouse() *Mouse

func (*Mouse) OnCollisionEnter

func (m *Mouse) OnCollisionEnter(arbiter Arbiter) bool

func (*Mouse) OnCollisionExit

func (m *Mouse) OnCollisionExit(arbiter Arbiter)

func (*Mouse) OnComponentAdd

func (m *Mouse) OnComponentAdd()

func (*Mouse) Start

func (m *Mouse) Start()

func (*Mouse) Update

func (m *Mouse) Update()

type OnAnimationEnd

type OnAnimationEnd func(sprite *Sprite)

type Physics

type Physics struct {
	BaseComponent
	Body  *chipmunk.Body
	Box   *chipmunk.BoxShape
	Shape *chipmunk.Shape

	Interpolate bool
	// contains filtered or unexported fields
}

func NewPhysics

func NewPhysics(static bool) *Physics

func NewPhysicsCircle

func NewPhysicsCircle(static bool) *Physics

func NewPhysicsShape

func NewPhysicsShape(static bool, shape *chipmunk.Shape) *Physics

func NewPhysicsShapes

func NewPhysicsShapes(static bool, shapes []*chipmunk.Shape) *Physics

func (*Physics) Clone

func (p *Physics) Clone()

func (*Physics) CollisionEnter

func (p *Physics) CollisionEnter(arbiter *chipmunk.Arbiter) bool

func (*Physics) CollisionExit

func (p *Physics) CollisionExit(arbiter *chipmunk.Arbiter)

func (*Physics) CollisionPostSolve

func (p *Physics) CollisionPostSolve(arbiter *chipmunk.Arbiter)

func (*Physics) CollisionPreSolve

func (p *Physics) CollisionPreSolve(arbiter *chipmunk.Arbiter) bool

func (*Physics) OnComponentAdd

func (p *Physics) OnComponentAdd()

func (*Physics) OnDestroy

func (p *Physics) OnDestroy()

func (*Physics) OnDisable

func (p *Physics) OnDisable()

func (*Physics) OnEnable

func (p *Physics) OnEnable()

func (*Physics) Start

func (p *Physics) Start()

type Program

type Program struct {
	gl.Program
}

func (Program) Use

func (p Program) Use()

type Rect

type Rect struct {
	Min, Max Vector
}

func (*Rect) Overlaps

func (r *Rect) Overlaps(s Rect) bool

type RectID

type RectID struct {
	Rect image.Rectangle
	ID   ID
}

type RectSortable

type RectSortable []image.Rectangle

func (RectSortable) Len

func (this RectSortable) Len() int

func (RectSortable) Less

func (this RectSortable) Less(i, j int) bool

func (RectSortable) Swap

func (this RectSortable) Swap(i, j int)

type ResID

type ResID interface{}

type Resource

type Resource interface {
	Release()
}

type Resources

type Resources struct {
	Resources map[ResID]Resource
}

func (*Resources) Add

func (r *Resources) Add(res Resource) error

func (*Resources) AddManual

func (r *Resources) AddManual(res Resource, key interface{}) error

func (*Resources) Release

func (r *Resources) Release()

func (*Resources) ReleaseResource

func (r *Resources) ReleaseResource(res interface{})

type Scene

type Scene interface {
	New() Scene
	Load()
	SceneBase() *SceneData
}

func GetScene

func GetScene() Scene

type SceneData

type SceneData struct {
	Camera *Camera
	// contains filtered or unexported fields
}

func NewScene

func NewScene(name string) *SceneData

func (*SceneData) AddGameObject

func (s *SceneData) AddGameObject(gameObject ...*GameObject)

func (*SceneData) Name

func (s *SceneData) Name() string

func (*SceneData) RemoveGameObject

func (s *SceneData) RemoveGameObject(g *GameObject)

func (*SceneData) SceneBase

func (s *SceneData) SceneBase() *SceneData

func (*SceneData) SetCamera

func (s *SceneData) SetCamera(Camera *Camera)

type Sprite

type Sprite struct {
	BaseComponent
	*Texture
	//buffer               gl.Buffer
	AnimationSpeed float32

	UVs AnimatedUV

	AnimationEndCallback OnAnimationEnd

	Tiling Vector

	Render bool

	Color Color
	// contains filtered or unexported fields
}

func NewSprite

func NewSprite(tex *Texture) *Sprite

func NewSprite2

func NewSprite2(tex *Texture, uv UV) *Sprite

func NewSprite3

func NewSprite3(tex *Texture, uv AnimatedUV) *Sprite

func (*Sprite) Align

func (p *Sprite) Align() Align

func (*Sprite) AnimationLength

func (sp *Sprite) AnimationLength() int

func (*Sprite) BindAnimations

func (p *Sprite) BindAnimations(animMap map[ID][2]int)

func (*Sprite) CurrentAnimation

func (p *Sprite) CurrentAnimation() interface{}

func (*Sprite) CurrentAnimationIndex

func (sp *Sprite) CurrentAnimationIndex() int

func (*Sprite) Draw

func (sp *Sprite) Draw()

func (*Sprite) DrawScreen

func (sp *Sprite) DrawScreen()

func (*Sprite) OnComponentAdd

func (sp *Sprite) OnComponentAdd()

func (*Sprite) RealSize

func (sp *Sprite) RealSize() (s Vector)

func (*Sprite) RealWorldSize

func (sp *Sprite) RealWorldSize() (s Vector)

func (*Sprite) SetAlign

func (p *Sprite) SetAlign(align Align)

func (*Sprite) SetAnimation

func (p *Sprite) SetAnimation(id ID)

func (*Sprite) SetAnimationIndex

func (sp *Sprite) SetAnimationIndex(index int)

func (*Sprite) Start

func (sp *Sprite) Start()

func (*Sprite) Update

func (sp *Sprite) Update()

func (*Sprite) UpdateShape

func (sp *Sprite) UpdateShape()

Todo: make this an interface.

type StaticBatch

type StaticBatch struct {
	Tex      *Texture
	Vertices VBO
	UVs      VBO
	Indecies VBO
	// contains filtered or unexported fields
}

func NewStaticBatch

func NewStaticBatch(tex *Texture) *StaticBatch

func (*StaticBatch) Add

func (this *StaticBatch) Add(position, scale Vector, rotation float32, uv UV) (index int)

func (*StaticBatch) Remove

func (this *StaticBatch) Remove(index int)

func (*StaticBatch) Render

func (this *StaticBatch) Render()

func (*StaticBatch) Update

func (this *StaticBatch) Update(position, scale Vector, rotation float32, uv UV, index int)

func (*StaticBatch) UpdateUV

func (this *StaticBatch) UpdateUV(uv UV, index int)

type Texture

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

func LoadTexture

func LoadTexture(path string) (tex *Texture, err error)

func LoadTextureFromImage

func LoadTextureFromImage(image image.Image) (tex *Texture, err error)

func NewRGBATexture

func NewRGBATexture(rgbaData interface{}, width int, height int) *Texture

func NewRGBTexture

func NewRGBTexture(rgbData interface{}, width int, height int) *Texture

func NewTexture

func NewTexture(image image.Image, data interface{}) (texture *Texture, err error)

func NewTexture2

func NewTexture2(data interface{}, width int, height int, target gl.GLenum, internalFormat int, typ gl.GLenum, format gl.GLenum) *Texture

func NewTextureEmpty

func NewTextureEmpty(width int, height int, model color.Model) *Texture

func (*Texture) Bind

func (t *Texture) Bind()

func (*Texture) BuildMipmaps

func (t *Texture) BuildMipmaps()

func (*Texture) GLTexture

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

func (*Texture) Height

func (t *Texture) Height() int

func (*Texture) Image

func (t *Texture) Image() image.Image

func (*Texture) Options

func (t *Texture) Options(filter, clamp int)

func (*Texture) Param

func (t *Texture) Param(filter, value int)

func (*Texture) Paramf

func (t *Texture) Paramf(filter int, value float32)

func (*Texture) PixelSize

func (t *Texture) PixelSize() int

func (*Texture) PreloadRender

func (t *Texture) PreloadRender()

func (*Texture) ReadTextureFromGPU

func (t *Texture) ReadTextureFromGPU() []byte

func (*Texture) Release

func (t *Texture) Release()

func (*Texture) Render

func (t *Texture) Render()

func (*Texture) SetData

func (t *Texture) SetData(data interface{})

func (*Texture) SetFiltering

func (t *Texture) SetFiltering(minFilter Filter, magFilter Filter)

func (*Texture) SetReadOnly

func (t *Texture) SetReadOnly()

func (*Texture) SetWraping

func (t *Texture) SetWraping(wrapType WrapType, wrap Wrap)

func (*Texture) Unbind

func (t *Texture) Unbind()

func (*Texture) Width

func (t *Texture) Width() int

type Timer

type Timer map[interface{}]time.Time

func NewTimer

func NewTimer() Timer

func (Timer) Defer

func (timer Timer) Defer(result *time.Duration) func()

func (Timer) DeferCustom

func (timer Timer) DeferCustom(key interface{}, result *time.Duration) func()

func (Timer) Start

func (timer Timer) Start()

func (Timer) StartCustom

func (timer Timer) StartCustom(key interface{})

func (Timer) Stop

func (timer Timer) Stop() time.Duration

func (Timer) StopCustom

func (timer Timer) StopCustom(key interface{}) time.Duration

type Transform

type Transform struct {
	BaseComponent
	// contains filtered or unexported fields
}

func NewTransform

func NewTransform() *Transform

func (*Transform) Angle

func (t *Transform) Angle() float32

func (*Transform) Child

func (t *Transform) Child(index int) *Transform

func (*Transform) Children

func (t *Transform) Children() []*Transform

func (*Transform) Clone

func (t *Transform) Clone()

func (*Transform) Depth

func (t *Transform) Depth() int

func (*Transform) Direction

func (t *Transform) Direction() Vector

func (*Transform) DirectionTransform

func (t *Transform) DirectionTransform(up Vector) Vector

func (*Transform) InScene

func (t *Transform) InScene() bool

Checking if object is somewhere in scene.

func (*Transform) InvertedMatrix

func (t *Transform) InvertedMatrix() Matrix

func (*Transform) Matrix

func (t *Transform) Matrix() Matrix

func (*Transform) OnComponentAdd

func (t *Transform) OnComponentAdd()

func (*Transform) Parent

func (t *Transform) Parent() *Transform

func (*Transform) Position

func (t *Transform) Position() Vector

func (*Transform) Rotation

func (t *Transform) Rotation() Vector

func (*Transform) Scale

func (t *Transform) Scale() Vector

func (*Transform) SetDepth

func (t *Transform) SetDepth(depth int)

func (*Transform) SetDepthRecursive

func (t *Transform) SetDepthRecursive(depth int)

func (*Transform) SetParent

func (t *Transform) SetParent(newParent *Transform)

func (*Transform) SetParent2

func (t *Transform) SetParent2(g *GameObject)

func (*Transform) SetPosition

func (t *Transform) SetPosition(vect Vector)

func (*Transform) SetPositionf

func (t *Transform) SetPositionf(x, y float32)

func (*Transform) SetRotation

func (t *Transform) SetRotation(vect Vector)

func (*Transform) SetRotationf

func (t *Transform) SetRotationf(z float32)

func (*Transform) SetScale

func (t *Transform) SetScale(vect Vector)

func (*Transform) SetScalef

func (t *Transform) SetScalef(x, y float32)

func (*Transform) SetWorldPosition

func (t *Transform) SetWorldPosition(vect Vector)

func (*Transform) SetWorldPositionf

func (t *Transform) SetWorldPositionf(x, y float32)

func (*Transform) SetWorldRotation

func (t *Transform) SetWorldRotation(vect Vector)

func (*Transform) SetWorldRotationf

func (t *Transform) SetWorldRotationf(z float32)

func (*Transform) SetWorldScale

func (t *Transform) SetWorldScale(vect Vector)

func (*Transform) SetWorldScalef

func (t *Transform) SetWorldScalef(x, y float32)

func (*Transform) Translate

func (t *Transform) Translate(v Vector)

func (*Transform) Translatef

func (t *Transform) Translatef(x, y float32)

func (*Transform) WorldPosition

func (t *Transform) WorldPosition() Vector

func (*Transform) WorldRotation

func (t *Transform) WorldRotation() Vector

func (*Transform) WorldScale

func (t *Transform) WorldScale() Vector

type UV

type UV struct {
	U1, V1, U2, V2, Ratio float32
}

func IndexUV

func IndexUV(a Atlas, id ID) UV

func NewUV

func NewUV(u1, v1, u2, v2, ratio float32) UV

type VAO

type VAO gl.VertexArray

func GenVertexArray

func GenVertexArray() VAO

func (VAO) Bind

func (this VAO) Bind()

type VBO

type VBO gl.Buffer

func GenBuffer

func GenBuffer() VBO

func (VBO) Bind

func (this VBO) Bind(target gl.GLenum)

type Vector

type Vector struct {
	X, Y, Z float32
}

func Lerp

func Lerp(from, to Vector, t float32) Vector

func NewVector2

func NewVector2(x, y float32) Vector

func NewVector3

func NewVector3(x, y, z float32) Vector

func (*Vector) Add

func (v *Vector) Add(vect Vector) Vector

func (*Vector) Distance

func (v *Vector) Distance(vect Vector) float32

func (*Vector) Div

func (v *Vector) Div(vect Vector) Vector

func (*Vector) Length

func (v *Vector) Length() float32

func (*Vector) Mul

func (v *Vector) Mul(vect Vector) Vector

func (*Vector) Mul2

func (v *Vector) Mul2(vect float32) Vector

func (*Vector) Normalize

func (v *Vector) Normalize()

func (*Vector) Normalized

func (v *Vector) Normalized() Vector

func (*Vector) String

func (v *Vector) String() string

func (*Vector) Sub

func (v *Vector) Sub(vect Vector) Vector

func (*Vector) Transform

func (v *Vector) Transform(transform Matrix) Vector

type Wrap

type Wrap int

type WrapType

type WrapType int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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