Documentation ¶
Index ¶
- Constants
- type BaseGobject
- func (o BaseGobject) Build() Gobject
- func (o *BaseGobject) DrawSprite(on *ebiten.Image, l *GridLayer)
- func (o *BaseGobject) IsVisible() bool
- func (o *BaseGobject) Name() string
- func (o *BaseGobject) NextFrame()
- func (o *BaseGobject) SetFrame(i int)
- func (o *BaseGobject) SetImageSequence(name string) error
- func (o *BaseGobject) SetSpritePack(sp SpritePack)
- func (o *BaseGobject) Sprite() *ebiten.Image
- func (o *BaseGobject) XY() (int, int)
- type EgridenAssets
- func (g *EgridenAssets) CreateGridLayerOnTop(name string, squareLength int, width, height int, drawMode drawMode, ...) *GridLayer
- func (g EgridenAssets) DrawAllLayers(screen *ebiten.Image)
- func (g EgridenAssets) GridLayer(z int) *GridLayer
- func (g EgridenAssets) GridLayers() []*GridLayer
- func (g *EgridenAssets) InitEgridenComponents()
- func (g *EgridenAssets) RunUpdateScripts()
- type Gobject
- type GridLayer
- type ImageSequence
- type SpritePack
Constants ¶
const ( //Used for sparcely populated grids, ranges over a map for drawing Sparce drawMode = iota //Used for thickly populated grids, ranges over a slice for drawing Dense //Used for layers that don't get updated often, creates ebiten.Image of the the entire layer. //Can be refreshed with GridLayer.RefreshImage(). Static )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseGobject ¶
type BaseGobject struct {
// contains filtered or unexported fields
}
The BaseGobject. Use it for simple Gobjects or implement your own Gobject by embedding this struct in your own.
func NewBaseGobject ¶
func NewBaseGobject(name string, sprites SpritePack) BaseGobject
Create a new BaseGobject. Use BaseGobject.Build() to create a scriptless Gobject that can be added to a layer
func (BaseGobject) Build ¶
func (o BaseGobject) Build() Gobject
Makes a BaseGobject respect Gobject interface by assigning it nil draw update etc. functions
For Gobjects with custom scripts you must create your own build function.
func (*BaseGobject) DrawSprite ¶
func (o *BaseGobject) DrawSprite(on *ebiten.Image, l *GridLayer)
Default function for drawing the sprite in the grid, shouldn't be overwritten.
func (*BaseGobject) IsVisible ¶
func (o *BaseGobject) IsVisible() bool
func (*BaseGobject) Name ¶
func (o *BaseGobject) Name() string
func (*BaseGobject) NextFrame ¶
func (o *BaseGobject) NextFrame()
Increments frame by one. Wraps back to 0 if out of range.
func (*BaseGobject) SetFrame ¶
func (o *BaseGobject) SetFrame(i int)
Sets the frame to `i % len(frames)`
func (*BaseGobject) SetImageSequence ¶
func (o *BaseGobject) SetImageSequence(name string) error
Sets Image Sequence under name, returns error if the name key is not present
func (*BaseGobject) SetSpritePack ¶
func (o *BaseGobject) SetSpritePack(sp SpritePack)
Assigns Sprite Pack. Should not be used during game updates.
func (*BaseGobject) Sprite ¶
func (o *BaseGobject) Sprite() *ebiten.Image
Returns the current sprite. Used for built-in drawing.
func (*BaseGobject) XY ¶
func (o *BaseGobject) XY() (int, int)
type EgridenAssets ¶
type EgridenAssets struct {
// contains filtered or unexported fields
}
func (*EgridenAssets) CreateGridLayerOnTop ¶
func (g *EgridenAssets) CreateGridLayerOnTop(name string, squareLength int, width, height int, drawMode drawMode, XOffset, YOffset float64) *GridLayer
Creates a grid layer at the lowest empty Z and returns a pointer to it.
See drawMode constants for which one you can use, but for small grids Sparce/Dense doesn't make much of a difference.
func (EgridenAssets) DrawAllLayers ¶
func (g EgridenAssets) DrawAllLayers(screen *ebiten.Image)
Draw all GridLayers in their Z order. Use this in the Draw() function.
func (EgridenAssets) GridLayer ¶
func (g EgridenAssets) GridLayer(z int) *GridLayer
Returns a GridLayer at z, panics if out of bounds
func (EgridenAssets) GridLayers ¶
func (g EgridenAssets) GridLayers() []*GridLayer
func (*EgridenAssets) InitEgridenComponents ¶
func (g *EgridenAssets) InitEgridenComponents()
Run this while initalizing the game, before adding any layers
func (*EgridenAssets) RunUpdateScripts ¶
func (g *EgridenAssets) RunUpdateScripts()
Run all the OnUpdate() scripts of Gobjects that have them. Use this in the Update() function.
type Gobject ¶
type Gobject interface { Name() string XY() (int, int) IsVisible() bool Sprite() *ebiten.Image SetImageSequence(string) error NextFrame() SetFrame(int) OnUpdate() func() //Runs every game.Update() call OnDraw() func(*ebiten.Image, *GridLayer) //Runs ever game.Draw() call DrawSprite(*ebiten.Image, *GridLayer) //Default sprite drawing function // contains filtered or unexported methods }
Gobject is an object that exists in a layer
type GridLayer ¶
type GridLayer struct { Name string Z int SquareLength int Width, Height int Visible bool XOffset, YOffset float64 NumOfGobjects int // contains filtered or unexported fields }
func (*GridLayer) AddObject ¶
Adds Gobject to the layer at x y. Will overwrite the any existing Gobject there.
func (GridLayer) IsOccupiedAt ¶
func (*GridLayer) RefreshImage ¶
func (l *GridLayer) RefreshImage()
func (*GridLayer) SetVisibility ¶
False visibility disables drawing both the Sprites and custom draw scripts of all Gobjects.
type ImageSequence ¶
type ImageSequence struct {
// contains filtered or unexported fields
}
ImageSequence is a sequence of images aka frames.
func CreateImageSequenceFromFolder ¶
func CreateImageSequenceFromFolder(name, folderPath string) (ImageSequence, error)
Searches for PNG files in the folder and creates an ImageSequence, with frame order based on the alphabetical order of the file names.
func CreateImageSequenceFromPaths ¶
func CreateImageSequenceFromPaths(name string, paths ...string) (ImageSequence, error)
Create an ImageSequence using multiple (or just one) file paths.
type SpritePack ¶
type SpritePack struct {
// contains filtered or unexported fields
}
SpritePack is a collection of ImageSequences and controls things like the frame index.
func EmptySpritePack ¶
func EmptySpritePack() SpritePack
A sprite pack that will not render anything
func NewSpritePack ¶
func NewSpritePack() SpritePack
func NewSpritePackWithSequence ¶
func NewSpritePackWithSequence(is ImageSequence) SpritePack
Create SpritePack and assign sequence
func NewSpritePackWithSequences ¶
func NewSpritePackWithSequences(is ...ImageSequence) SpritePack
Create SpritePack and assign multiple sequences
func (*SpritePack) AddImageSequence ¶
func (ip *SpritePack) AddImageSequence(is ImageSequence)
Assigns an ImageSequence to SpritePack
func (SpritePack) Sprite ¶
func (sp SpritePack) Sprite() *ebiten.Image