engi

package module
Version: v0.0.0-...-bc3f8cd Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: BSD-2-Clause Imports: 20 Imported by: 0

README

engi

engi is a multi-platform 2D game library for Go, forked from ENGi v0.6.0. After much bitrot and many broken builds, I have ported it to be a thin wrapper over Ebiten.

This is mainly to ease the transition from old engi to Ebiten. I didn't bother porting stuff I didn't use.

There is pretty much no reason to use this unless you are trying to resurrect and old engi game. Use Ebiten instead.

Used in

Documentation

Index

Constants

This section is empty.

Variables

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        = ebiten.KeyMinus
	Apostrophe  = ebiten.KeyApostrophe
	Semicolon   = ebiten.KeySemicolon
	Equals      = ebiten.KeyEqual
	Comma       = ebiten.KeyComma
	Period      = ebiten.KeyPeriod
	Slash       = ebiten.KeySlash
	Backslash   = ebiten.KeyBackslash
	Backspace   = ebiten.KeyBackspace
	Tab         = ebiten.KeyTab
	CapsLock    = ebiten.KeyCapsLock
	Space       = ebiten.KeySpace
	Enter       = ebiten.KeyEnter
	Escape      = ebiten.KeyEscape
	Insert      = ebiten.KeyInsert
	PrintScreen = ebiten.KeyPrintScreen
	Delete      = ebiten.KeyDelete
	PageUp      = ebiten.KeyPageUp
	PageDown    = ebiten.KeyPageDown
	Home        = ebiten.KeyHome
	End         = ebiten.KeyEnd
	Pause       = ebiten.KeyPause
	ScrollLock  = ebiten.KeyScrollLock
	ArrowLeft   = ebiten.KeyLeft
	ArrowRight  = ebiten.KeyRight
	ArrowDown   = ebiten.KeyDown
	ArrowUp     = ebiten.KeyUp
	LeftBracket = ebiten.KeyLeftBracket
	LeftShift   = ebiten.KeyShift
	LeftControl = ebiten.KeyControl
	// LeftSuper    = ebiten.KeySuper
	LeftAlt      = ebiten.KeyAlt
	RightBracket = ebiten.KeyRightBracket
	RightShift   = ebiten.KeyShift
	RightControl = ebiten.KeyControl
	// RightSuper   = ebiten.Super
	RightAlt = ebiten.KeyAlt
	Zero     = ebiten.Key0
	One      = ebiten.Key1
	Two      = ebiten.Key2
	Three    = ebiten.Key3
	Four     = ebiten.Key4
	Five     = ebiten.Key5
	Six      = ebiten.Key6
	Seven    = ebiten.Key7
	Eight    = ebiten.Key8
	Nine     = ebiten.Key9
	F1       = ebiten.KeyF1
	F2       = ebiten.KeyF2
	F3       = ebiten.KeyF3
	F4       = ebiten.KeyF4
	F5       = ebiten.KeyF5
	F6       = ebiten.KeyF6
	F7       = ebiten.KeyF7
	F8       = ebiten.KeyF8
	F9       = ebiten.KeyF9
	F10      = ebiten.KeyF10
	F11      = ebiten.KeyF11
	F12      = ebiten.KeyF12
	A        = ebiten.KeyA
	B        = ebiten.KeyB
	C        = ebiten.KeyC
	D        = ebiten.KeyD
	E        = ebiten.KeyE
	F        = ebiten.KeyF
	G        = ebiten.KeyG
	H        = ebiten.KeyH
	I        = ebiten.KeyI
	J        = ebiten.KeyJ
	K        = ebiten.KeyK
	L        = ebiten.KeyL
	M        = ebiten.KeyM
	N        = ebiten.KeyN
	O        = ebiten.KeyO
	P        = ebiten.KeyP
	Q        = ebiten.KeyQ
	R        = ebiten.KeyR
	S        = ebiten.KeyS
	T        = ebiten.KeyT
	U        = ebiten.KeyU
	V        = ebiten.KeyV
	W        = ebiten.KeyW
	X        = ebiten.KeyX
	Y        = ebiten.KeyY
	Z        = ebiten.KeyZ
	NumLock  = ebiten.KeyNumLock
)
View Source
var OnClose func()

Functions

func AppDir

func AppDir() string

func Exit

func Exit()

func Height

func Height() float64

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(c uint32)

func SetGain

func SetGain(g float64)

func ToggleMute

func ToggleMute()

func Width

func Width() float64

Types

type Action

type Action int

type Batch

type Batch struct {
}

func NewBatch

func NewBatch(width, height float64) *Batch

func (*Batch) Begin

func (b *Batch) Begin()

func (*Batch) Draw

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

func (*Batch) Draw2

func (b *Batch) Draw2(img *ebiten.Image, opt *ebiten.DrawImageOptions)

func (*Batch) End

func (b *Batch) End()

func (*Batch) Screen

func (b *Batch) Screen() *ebiten.Image

func (*Batch) SetProjection

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

type Drawable

type Drawable interface {
	Texture() *ebiten.Image
	Width() float64
	Height() float64
	View() (float64, float64, float64, float64)
}

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 float64, color uint32)

func (*Font) Put

func (f *Font) Put(batch *Batch, r rune, x, y float64, 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 int, 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 float64)

func (*Game) Setup

func (g *Game) Setup()

func (*Game) Type

func (g *Game) Type(char rune)

func (*Game) Update

func (g *Game) Update(dt float64)

type Image

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

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 = ebiten.Key

type Loader

type Loader struct {
	// contains filtered or unexported fields
}
var (
	Files *Loader
)

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

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

func (*Loader) SFX

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

func (*Loader) Sound

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

func (*Loader) Text

func (l *Loader) Text(name string) []byte

type Modifier

type Modifier int

type Key int

type Music

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

func (*Music) Delete

func (s *Music) Delete()

func (*Music) Loop

func (s *Music) Loop()

func (*Music) Play

func (s *Music) Play()

func (*Music) PlayAt

func (s *Music) PlayAt(mult float64)

func (*Music) Playing

func (s *Music) Playing() bool

func (*Music) Stop

func (s *Music) Stop()

type Point

type Point struct {
	X, Y float64
}

func (*Point) Set

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

func (*Point) SetTo

func (p *Point) SetTo(v float64)

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

func (*Region) Texture

func (r *Region) Texture() *ebiten.Image

func (*Region) View

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

func (*Region) Width

func (r *Region) Width() float64

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 float64)
	Mouse(x, y int, action Action)
	Scroll(amount float64)
	Key(key Key, modifier Modifier, action Action)
	Type(char rune)
}

type SFX

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

func (*SFX) Delete

func (s *SFX) Delete()

func (*SFX) Duration

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

func (*SFX) Loop

func (s *SFX) Loop()

func (*SFX) Play

func (s *SFX) Play()

func (*SFX) PlayAt

func (s *SFX) PlayAt(gainMultiplier float64)

func (*SFX) Playing

func (s *SFX) Playing() bool

func (*SFX) Stop

func (s *SFX) Stop()

type Sound

type Sound interface {
	Play()
	PlayAt(mult float64)
	Loop()
	Stop()
	Playing() bool
}

type Sprite

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

func NewSprite

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

func (*Sprite) Render

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

type Texture

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

func NewTexture

func NewTexture(img Image) *Texture

func (*Texture) Height

func (t *Texture) Height() float64

Height returns the height of the texture.

func (*Texture) Texture

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

func (*Texture) View

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

func (*Texture) Width

func (t *Texture) Width() float64

Width returns the width of the texture.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to