engi

package module
v0.0.0-...-7be04f6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2016 License: BSD-2-Clause Imports: 20 Imported by: 0

README

engi

import github.com/guregu/engi

engi (演技) is a multi-platform 2D game library for Go, forked from ENGi v0.6.0.

Documentation

godoc.org

Status

SUPER ALPHA. Especially the audio bits.

Differences from original engi

  • Mostly working audio support
  • Uses newer GLFW, fixes VSync issues.
  • JS version is broken

Audio

Sounds are loaded entirely in to memory, designed for sound effects. Files ending with .flac, and .wav will be loaded as Sounds.

Streams are streamed, designed for background music. Files ending with .flac-s. This system is pretty dumb/hacky so I will fix it eventually.

Desktop

The desktop backend depends on glfw3, but includes the source code and links it statically. If you are having linker errors on Windows, I suggest using TDM-GCC instead of MinGW as your cgo compiler. Linux may need xorg-dev.

Web

This fork has broken GopherJS support for the time being.

Install

go get -u github.com/guregu/engi

Success stories

Other libraries

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Time  *Clock
	Files *Loader
)
View Source
var (
	MOVE    = Action(0)
	PRESS   = Action(1)
	RELEASE = Action(2)
	SHIFT   = Modifier(0x0001)
	CONTROL = Modifier(0x0002)
	ALT     = Modifier(0x0004)
	SUPER   = Modifier(0x0008)
)
View Source
var (
	Dash         = Key(189)
	Apostrophe   = Key(222)
	Semicolon    = Key(186)
	Equals       = Key(187)
	Comma        = Key(188)
	Period       = Key(190)
	Slash        = Key(191)
	Backslash    = Key(220)
	Backspace    = Key(8)
	Tab          = Key(9)
	CapsLock     = Key(20)
	Space        = Key(32)
	Enter        = Key(13)
	Escape       = Key(27)
	Insert       = Key(45)
	PrintScreen  = Key(42)
	Delete       = Key(46)
	PageUp       = Key(33)
	PageDown     = Key(34)
	Home         = Key(36)
	End          = Key(35)
	Pause        = Key(19)
	ScrollLock   = Key(145)
	ArrowLeft    = Key(37)
	ArrowRight   = Key(39)
	ArrowDown    = Key(40)
	ArrowUp      = Key(38)
	LeftBracket  = Key(219)
	LeftShift    = Key(16)
	LeftControl  = Key(17)
	LeftSuper    = Key(73)
	LeftAlt      = Key(18)
	RightBracket = Key(221)
	RightShift   = Key(16)
	RightControl = Key(17)
	RightSuper   = Key(73)
	RightAlt     = Key(18)
	Zero         = Key(48)
	One          = Key(49)
	Two          = Key(50)
	Three        = Key(51)
	Four         = Key(52)
	Five         = Key(53)
	Six          = Key(54)
	Seven        = Key(55)
	Eight        = Key(56)
	Nine         = Key(57)
	F1           = Key(112)
	F2           = Key(113)
	F3           = Key(114)
	F4           = Key(115)
	F5           = Key(116)
	F6           = Key(117)
	F7           = Key(118)
	F8           = Key(119)
	F9           = Key(120)
	F10          = Key(121)
	F11          = Key(122)
	F12          = Key(123)
	A            = Key(65)
	B            = Key(66)
	C            = Key(67)
	D            = Key(68)
	E            = Key(69)
	F            = Key(70)
	G            = Key(71)
	H            = Key(72)
	I            = Key(73)
	J            = Key(74)
	K            = Key(75)
	L            = Key(76)
	M            = Key(77)
	N            = Key(78)
	O            = Key(79)
	P            = Key(80)
	Q            = Key(81)
	R            = Key(82)
	S            = Key(83)
	T            = Key(84)
	U            = Key(85)
	V            = Key(86)
	W            = Key(87)
	X            = Key(88)
	Y            = Key(89)
	Z            = Key(90)
	NumLock      = Key(144)
	NumMultiply  = Key(106)
	NumDivide    = Key(111)
	NumAdd       = Key(107)
	NumSubtract  = Key(109)
	NumZero      = Key(96)
	NumOne       = Key(97)
	NumTwo       = Key(98)
	NumThree     = Key(99)
	NumFour      = Key(100)
	NumFive      = Key(101)
	NumSix       = Key(102)
	NumSeven     = Key(103)
	NumEight     = Key(104)
	NumNine      = Key(105)
	NumDecimal   = Key(110)
	NumEnter     = Key(13)
)
View Source
var (
	MouseMove         = MouseKey(-1)
	MouseButton1      = MouseKey(0)
	MouseButton2      = MouseKey(1)
	MouseButton3      = MouseKey(2)
	MouseButton4      = MouseKey(3)
	MouseButton5      = MouseKey(4)
	MouseButton6      = MouseKey(5)
	MouseButton7      = MouseKey(6)
	MouseButton8      = MouseKey(7)
	MouseButtonLast   = MouseKey(8)
	MouseButtonLeft   = MouseKey(9)
	MouseButtonRight  = MouseKey(10)
	MouseButtonMiddle = MouseKey(11)
)

Functions

func AppDir

func AppDir() string

func Exit

func Exit()

func Height

func Height() float32

func LoadShader

func LoadShader(vertSrc, fragSrc string) *webgl.Program

func Minimize

func Minimize()

func Muted

func Muted() bool

func Open

func Open(title string, width, height int, fullscreen bool, r Responder)

func SetBg

func SetBg(color uint32)

func ToggleMute

func ToggleMute()

func Width

func Width() float32

Types

type Action

type Action int

type Assets

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

func NewAssets

func NewAssets() *Assets

func (*Assets) Get

func (a *Assets) Get(path string) Image

func (*Assets) Image

func (a *Assets) Image(path string)

func (*Assets) Load

func (a *Assets) Load(onFinish func())

type Batch

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

func NewBatch

func NewBatch(width, height float32) *Batch

func (*Batch) Begin

func (b *Batch) Begin()

func (*Batch) Draw

func (b *Batch) Draw(r Drawable, x, y, originX, originY, scaleX, scaleY, rotation float32, color uint32, transparency float32)

func (*Batch) End

func (b *Batch) End()

func (*Batch) SetProjection

func (b *Batch) SetProjection(width, height float32)

type Clock

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

func NewClock

func NewClock() *Clock

func (*Clock) Delta

func (c *Clock) Delta() float32

func (*Clock) Fps

func (c *Clock) Fps() float32

func (*Clock) Tick

func (c *Clock) Tick()

func (*Clock) Time

func (c *Clock) Time() float32

type Drawable

type Drawable interface {
	Texture() *webgl.Texture
	Width() float32
	Height() float32
	View() (float32, float32, float32, float32)
}

type Font

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

func NewGridFont

func NewGridFont(texture *Texture, cellWidth, cellHeight int) *Font

func (*Font) Print

func (f *Font) Print(batch *Batch, text string, x, y float32, color uint32)

func (*Font) Put

func (f *Font) Put(batch *Batch, r rune, x, y float32, color uint32)

func (*Font) Remap

func (f *Font) Remap(mapping string)

type Game

type Game struct{}

func (*Game) Close

func (g *Game) Close()

func (*Game) Key

func (g *Game) Key(key Key, modifier Modifier, action Action)

func (*Game) Mouse

func (g *Game) Mouse(x, y float32, key MouseKey, action Action)

func (*Game) Preload

func (g *Game) Preload()

func (*Game) Render

func (g *Game) Render()

func (*Game) Resize

func (g *Game) Resize(w, h int)

func (*Game) Scroll

func (g *Game) Scroll(amount float32)

func (*Game) Setup

func (g *Game) Setup()

func (*Game) Type

func (g *Game) Type(char rune)

func (*Game) Update

func (g *Game) Update(dt float32)

type Image

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

func LoadImage

func LoadImage(data interface{}) Image

type ImageObject

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

func NewImageObject

func NewImageObject(img *image.NRGBA) *ImageObject

func (*ImageObject) Data

func (i *ImageObject) Data() interface{}

func (*ImageObject) Height

func (i *ImageObject) Height() int

func (*ImageObject) Width

func (i *ImageObject) Width() int

type Key

type Key int

type Loader

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

func NewLoader

func NewLoader() *Loader

func (*Loader) Add

func (l *Loader) Add(name, url string)

func (*Loader) AddReader

func (l *Loader) AddReader(name, kind string, r io.Reader)

func (*Loader) Image

func (l *Loader) Image(name string) *Texture

func (*Loader) Json

func (l *Loader) Json(name string) string

func (*Loader) Load

func (l *Loader) Load(onFinish func())

func (*Loader) Sound

func (l *Loader) Sound(name string) *Sound

func (*Loader) Stream

func (l *Loader) Stream(name string) *Stream

type Modifier

type Modifier int

type MouseKey

type MouseKey int

type Point

type Point struct {
	X, Y float32
}

func (*Point) Set

func (p *Point) Set(x, y float32)

func (*Point) SetTo

func (p *Point) SetTo(v float32)

type Region

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

func NewRegion

func NewRegion(texture *Texture, x, y, w, h int) *Region

func (*Region) Height

func (r *Region) Height() float32

func (*Region) Texture

func (r *Region) Texture() *webgl.Texture

func (*Region) View

func (r *Region) View() (float32, float32, float32, float32)

func (*Region) Width

func (r *Region) Width() float32

type Resource

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

type Responder

type Responder interface {
	Render()
	Resize(width, height int)
	Preload()
	Setup()
	Close()
	Update(dt float32)
	Mouse(x, y float32, key MouseKey, action Action)
	Scroll(amount float32)
	Key(key Key, modifier Modifier, action Action)
	Type(char rune)
}

type Sound

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

func (*Sound) Delete

func (s *Sound) Delete()

func (*Sound) Duration

func (s *Sound) Duration() time.Duration

func (*Sound) Loop

func (s *Sound) Loop()

func (*Sound) Play

func (s *Sound) Play()

func (*Sound) Playing

func (s *Sound) Playing() bool

func (*Sound) Stop

func (s *Sound) Stop()

type Sprite

type Sprite struct {
	Position *Point
	Scale    *Point
	Anchor   *Point
	Rotation float32
	Color    uint32
	Alpha    float32
	Region   *Region
}

func NewSprite

func NewSprite(region *Region, x, y float32) *Sprite

func (*Sprite) Render

func (s *Sprite) Render(batch *Batch)

type Stream

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

func (*Stream) Delete

func (s *Stream) Delete()

func (*Stream) Loop

func (s *Stream) Loop()

func (*Stream) Play

func (s *Stream) Play()

func (*Stream) Playing

func (s *Stream) Playing() bool

func (*Stream) Stop

func (s *Stream) Stop()

type Texture

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

func NewTexture

func NewTexture(img Image) *Texture

func (*Texture) Height

func (t *Texture) Height() float32

Height returns the height of the texture.

func (*Texture) Texture

func (t *Texture) Texture() *webgl.Texture

func (*Texture) View

func (r *Texture) View() (float32, float32, float32, float32)

func (*Texture) Width

func (t *Texture) Width() float32

Width returns the width of the texture.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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