primen

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: BSD-2-Clause, MIT Imports: 12 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	Layer0  core.LayerIndex = 0
	Layer1  core.LayerIndex = 1
	Layer2  core.LayerIndex = 2
	Layer3  core.LayerIndex = 3
	Layer4  core.LayerIndex = 4
	Layer5  core.LayerIndex = 5
	Layer6  core.LayerIndex = 6
	Layer7  core.LayerIndex = 7
	Layer8  core.LayerIndex = 8
	Layer9  core.LayerIndex = 9
	Layer10 core.LayerIndex = 10
	Layer11 core.LayerIndex = 11
	Layer12 core.LayerIndex = 12
	Layer13 core.LayerIndex = 13
	Layer14 core.LayerIndex = 14
	Layer15 core.LayerIndex = 15
)

LAYERS

View Source
const TagDelta = "delta"

TagDelta is the key set of the time taken between frames (in seconds)

Variables

This section is empty.

Functions

func SetFuncs

func SetFuncs(w *ecs.World, entity ecs.Entity, beforefn, fn, afterfn core.UpdateFn) error

SetFuncs adds a component with the specified functions

Types

type Context

type Context interface {
	ecs.Context
	Engine() *Engine
	FPS() float64
	Frame() int64
	IsDrawingSkipped() bool
	DefaultDrawImageOptions() *ebiten.DrawImageOptions
	Screen() *ebiten.Image
}

Context is the context passed to every system update function.

type Dict

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

Dict is a concurrency-safe map.

func (*Dict) Exists

func (d *Dict) Exists(key string) bool

Exists checks if the item exists

func (*Dict) Get

func (d *Dict) Get(key string) interface{}

Get an item

func (*Dict) Set

func (d *Dict) Set(key string, value interface{})

Set an item

type Engine

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

Engine is what controls the ECS of primen.

func NewEngine

func NewEngine(v *NewEngineInput) *Engine

NewEngine returns a new Engine

func (*Engine) AddEventListener

func (e *Engine) AddEventListener(eventName string, fn core.EventFn) core.EventID

func (*Engine) AddWorld

func (e *Engine) AddWorld(w *ecs.World, priority int)

AddWorld adds a world to the engine. The priority is used to sort world execution, from hight to low.

func (*Engine) Default

func (e *Engine) Default() *ecs.World

Default world

func (*Engine) DispatchEvent

func (e *Engine) DispatchEvent(eventName string, data interface{})

func (*Engine) Draw

func (e *Engine) Draw(screen *ebiten.Image)

func (*Engine) DrawFrame

func (e *Engine) DrawFrame() int64

DrawFrame returns the current frame. Use ctx.Frame() (more performant)

func (*Engine) FS

func (e *Engine) FS() io.Filesystem

FS returns the filesystem

func (*Engine) Get

func (e *Engine) Get(key string) interface{}

Get an item from the global map

func (*Engine) Height

func (e *Engine) Height() int

Height returns the logical height

func (*Engine) Layout

func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int)

Layout for ebiten.Game inteface

func (*Engine) Ready

func (e *Engine) Ready() <-chan struct{}

Ready returns a channel that signals when the engine is ready

func (*Engine) RemoveEventListener

func (e *Engine) RemoveEventListener(id core.EventID) bool

func (*Engine) RemoveWorld

func (e *Engine) RemoveWorld(w *ecs.World) bool

RemoveWorld removes a *World

func (*Engine) Run

func (e *Engine) Run() error

Run boots up the game engine

func (*Engine) Set

func (e *Engine) Set(key string, value interface{})

Set an item to the global map

func (*Engine) Update

func (e *Engine) Update(screen *ebiten.Image) error

func (*Engine) UpdateFrame

func (e *Engine) UpdateFrame() int64

UpdateFrame returns the current frame. Use ctx.Frame() (more performant)

func (*Engine) Width

func (e *Engine) Width() int

Width returns the logical width

type EngineOptions

type EngineOptions struct {
	Width               int
	Height              int
	Scale               int
	Title               string
	IsFullscreen        bool
	IsResizable         bool
	IsMaxResolution     bool
	IsTransparentScreen bool
	IsFloating          bool
	IsMaximized         bool
}

EngineOptions is used to setup Ebiten @ Engine.boot

type NewEngineInput

type NewEngineInput struct {
	Width             int             // main window width
	Height            int             // main wndow height
	Scale             int             // pixel scale (default: 1)
	TransparentScreen bool            // transparent screen
	Maximized         bool            // start window maximized
	Floating          bool            // always on top of all windows
	Fullscreen        bool            // start in fullscreen
	Resizable         bool            // is window resizable?
	FixedResolution   bool            // fixed logical screen resolution
	MaxResolution     bool            // set width/height to max resolution
	Title             string          // window title
	FS                io.Filesystem   // TODO: drop this
	OnReady           func(e *Engine) // function to run once the window is opened
}

NewEngineInput is the input data of NewEngine

func (*NewEngineInput) Options

func (i *NewEngineInput) Options() EngineOptions

Options will create a EngineOptions struct to be used in an *Engine

type Sprite

type Sprite struct {
	*WorldItem
	TauSprite *core.Sprite
	Transform *core.Transform
	DrawLayer *core.DrawLayer
}

func NewSprite

func NewSprite(w *ecs.World, im *ebiten.Image, layer core.LayerIndex, parent *core.Transform) *Sprite

type StepInfo

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

func (*StepInfo) Get

func (i *StepInfo) Get() (lt time.Time, frame int64)

func (*StepInfo) GetFrame

func (i *StepInfo) GetFrame() (frame int64)

func (*StepInfo) Set

func (i *StepInfo) Set(lt time.Time, frame int64)

type Transform

type Transform struct {
	*WorldItem
	TauTransform *core.Transform
}

func NewTransform

func NewTransform(w *ecs.World, parent *core.Transform) *Transform

type WorldItem

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

func (*WorldItem) Entity

func (wi *WorldItem) Entity() ecs.Entity

func (*WorldItem) UpsertFns

func (wi *WorldItem) UpsertFns(beforefn, fn, afterfn core.UpdateFn) bool

func (*WorldItem) World

func (wi *WorldItem) World() *ecs.World

type WorldTag

type WorldTag = string

WorldTag is a tag used to filter systems of a world

const (
	// WorldTagDraw -> systems that draw things
	WorldTagDraw WorldTag = "draw"
	// WorldTagUpdate -> systems that update things (!= draw)
	WorldTagUpdate WorldTag = "update"
)

Directories

Path Synopsis
cmd
editor command
tcli command
Package core contains lower level component systems.
Package core contains lower level component systems.
examples
animation command
hello command
layers command
layers/res
Code generated by broccoli at 2020-05-21T02:58:11-03:00.
Code generated by broccoli at 2020-05-21T02:58:11-03:00.
sprites command
transform2 command
internal
io
os
pb
utils

Jump to

Keyboard shortcuts

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