primen

package module
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 20 Imported by: 0

README

Primen

Primen is a 2D game engine written in Go following the Entity Component System paradigm. Primen is powered by the Ebiten game library.

Work In Progress

I'm developing this project along with a game, so the features are being added according with my game's priorities.

Planned Integrations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorFromHex added in v0.3.0

func ColorFromHex(hexv string) color.RGBA

ColorFromHex parses a RRGGBBAA (or RRGGBB) hexadecimal color into color.RGBA

Returns color.Transparent on invalid hex inputs.

func RegisterScene added in v0.6.1

func RegisterScene(name string, fn NewSceneFn)

RegisterScene registers a scene

func RegisteredScenes added in v0.6.1

func RegisteredScenes() map[string]NewSceneFn

Types

type AnimatedSpriteNode added in v0.5.0

type AnimatedSpriteNode struct {
	*SpriteNode
	// contains filtered or unexported fields
}

func NewChildAnimatedSpriteNode added in v0.5.0

func NewChildAnimatedSpriteNode(parent ObjectContainer, layer Layer, fps float64, anim graphics.Animation) *AnimatedSpriteNode

func NewRootAnimatedSpriteNode added in v0.5.0

func NewRootAnimatedSpriteNode(w World, layer Layer, fps float64, anim graphics.Animation) *AnimatedSpriteNode

func (AnimatedSpriteNode) AddChild added in v0.5.0

func (o AnimatedSpriteNode) AddChild(child Object)

func (AnimatedSpriteNode) Children added in v0.5.0

func (o AnimatedSpriteNode) Children() []Object

func (AnimatedSpriteNode) RemoveChild added in v0.5.0

func (o AnimatedSpriteNode) RemoveChild(child Object)

func (*AnimatedSpriteNode) SpriteAnim added in v0.5.0

func (n *AnimatedSpriteNode) SpriteAnim() *graphics.SpriteAnimation

type Animation added in v0.3.0

type Animation = graphics.Animation

type AudioPlayerNode added in v0.7.0

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

func NewChildAudioPlayerNode added in v0.7.0

func NewChildAudioPlayerNode(parent ObjectContainer, input components.NewAudioPlayerInput) *AudioPlayerNode

func NewRootAudioPlayerNode added in v0.7.0

func NewRootAudioPlayerNode(w World, input components.NewAudioPlayerInput) *AudioPlayerNode

func (AudioPlayerNode) AddChild added in v0.7.0

func (o AudioPlayerNode) AddChild(child Object)

func (*AudioPlayerNode) AudioPlayer added in v0.7.0

func (t *AudioPlayerNode) AudioPlayer() *components.AudioPlayer

func (AudioPlayerNode) Children added in v0.7.0

func (o AudioPlayerNode) Children() []Object

func (*AudioPlayerNode) Destroy added in v0.7.0

func (t *AudioPlayerNode) Destroy()

func (AudioPlayerNode) RemoveChild added in v0.7.0

func (o AudioPlayerNode) RemoveChild(child Object)

type AutoScene added in v0.7.2

type AutoScene interface {
	Scene
	PrevSceneCh(ch <-chan struct{})
}

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 DrawCtx added in v0.7.2

type DrawCtx = core.DrawCtx

type Engine

type Engine interface {
	core.Engine
	Ctx() context.Context
	Exit()
	FS() io.Filesystem
	LoadScene(name string) (scene Scene, sig chan struct{}, err error)
	RunFn(fn func())
	LastLoadedScene() Scene
	NewContainer() io.Container
	WaitAndGrabScreenImage() ScreenCopyRequest
	AddTempDrawFn(priority int, fn func(ctx core.DrawCtx) bool)
	NewDrawTarget(mask core.DrawMask, bounds geom.Rect, filter ebiten.Filter) core.DrawTargetID
	NewScreenOffsetDrawTarget(mask core.DrawMask) core.DrawTargetID
	NewProgrammableDrawTarget(input ProgrammableDrawTargetInput) core.DrawTargetID
	DrawTarget(id core.DrawTargetID) core.DrawTarget
	RemoveDrawTarget(id core.DrawTargetID) bool
}

func NewEngine

func NewEngine(v *NewEngineInput) Engine

NewEngine returns a new Engine

type EngineDrawManager added in v0.7.2

type EngineDrawManager interface {
	core.DrawManager
	DrawTargets()
	PrepareTargets()
}

type EngineDrawTarget added in v0.7.2

type EngineDrawTarget interface {
	core.DrawTarget
	PrepareFrame(screen *ebiten.Image)
	DrawFrame(screen *ebiten.Image)
}

type EngineOptions

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

EngineOptions is used to setup Ebiten @ Engine.boot

type Error added in v0.6.1

type Error string
const (
	ErrSceneNotFound Error = "scene not found"
)

func (Error) Error added in v0.6.1

func (e Error) Error() string

type FnNode added in v0.5.0

type FnNode struct {
	*Node
	// contains filtered or unexported fields
}

func NewRootFnNode added in v0.5.0

func NewRootFnNode(w World) *FnNode

func (FnNode) AddChild added in v0.5.0

func (o FnNode) AddChild(child Object)

func (FnNode) Children added in v0.5.0

func (o FnNode) Children() []Object

func (*FnNode) Function added in v0.5.0

func (n *FnNode) Function() *components.Function

Function retrieves the function component data

func (FnNode) RemoveChild added in v0.5.0

func (o FnNode) RemoveChild(child Object)

type LabelNode added in v0.5.0

type LabelNode struct {
	*Node
	// contains filtered or unexported fields
}

func NewChildLabelNode added in v0.5.0

func NewChildLabelNode(parent ObjectContainer, layer Layer) *LabelNode

func NewRootLabelNode added in v0.5.0

func NewRootLabelNode(w World, layer Layer) *LabelNode

func (LabelNode) AddChild added in v0.5.0

func (o LabelNode) AddChild(child Object)

func (LabelNode) Children added in v0.5.0

func (o LabelNode) Children() []Object

func (*LabelNode) Label added in v0.5.0

func (n *LabelNode) Label() *graphics.TextLabel

func (*LabelNode) Layer added in v0.5.0

func (n *LabelNode) Layer() Layer

func (LabelNode) RemoveChild added in v0.5.0

func (o LabelNode) RemoveChild(child Object)

func (*LabelNode) SetLayer added in v0.5.0

func (n *LabelNode) SetLayer(l Layer)

func (*LabelNode) SetZIndex added in v0.5.0

func (n *LabelNode) SetZIndex(index int64)

func (*LabelNode) ZIndex added in v0.5.0

func (n *LabelNode) ZIndex() int64

type Layer added in v0.3.0

type Layer = graphics.LayerIndex

Layer index type

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

LAYERS

type NewEngineInput

type NewEngineInput struct {
	Width             int            // main window width
	Height            int            // main window height
	Scale             float64        // 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
	FixedWidth        int            // fixed logical screen resolution
	FixedHeight       int            // fixed logical screen resolution
	MaxResolution     bool           // set width/height to max resolution
	Title             string         // window title
	FS                io.Filesystem  // the filesystem that the Scenes will use
	OnReady           func(e Engine) // function to run once the window is opened
	Scene             string         // Autoloads a starting scene on ready
}

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 NewSceneFn added in v0.6.1

type NewSceneFn func(engine Engine) (Scene, chan struct{})

type Node added in v0.5.0

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

func NewChildNode added in v0.5.0

func NewChildNode(parent ObjectContainer) *Node

func NewRootNode added in v0.5.0

func NewRootNode(w World) *Node

func (Node) AddChild added in v0.5.0

func (o Node) AddChild(child Object)

func (Node) Children added in v0.5.0

func (o Node) Children() []Object

func (*Node) Destroy added in v0.5.0

func (t *Node) Destroy()

func (Node) RemoveChild added in v0.5.0

func (o Node) RemoveChild(child Object)

func (*Node) SetParent added in v0.5.0

func (t *Node) SetParent(parent ObjectContainer)

func (*Node) TrTweening added in v0.7.0

func (t *Node) TrTweening() *components.TrTweening

func (*Node) Transform added in v0.5.0

func (t *Node) Transform() *components.Transform

type NodeWithAudioPlayer added in v0.7.0

type NodeWithAudioPlayer interface {
	AudioPlayer() *components.AudioPlayer
}

type NodeWithTransform added in v0.7.0

type NodeWithTransform interface {
	Transform() *components.Transform
}

type Object added in v0.3.0

type Object interface {
	Entity() ecs.Entity
	World() World
	Destroy()
	SetParent(parent ObjectContainer)
}

Object is the base of any Primen base ECS object

type ObjectContainer added in v0.3.0

type ObjectContainer interface {
	Object
	Children() []Object
	AddChild(child Object)
	RemoveChild(child Object)
}

ObjectContainer is an object that contains other objects

type ParticleEmitterNode added in v0.6.0

type ParticleEmitterNode struct {
	*Node
	// contains filtered or unexported fields
}

func NewChildParticleEmitterNode added in v0.6.0

func NewChildParticleEmitterNode(parent ObjectContainer, layer Layer) *ParticleEmitterNode

func NewRootParticleEmitterNode added in v0.6.0

func NewRootParticleEmitterNode(w World, layer Layer) *ParticleEmitterNode

func (ParticleEmitterNode) AddChild added in v0.6.0

func (o ParticleEmitterNode) AddChild(child Object)

func (ParticleEmitterNode) Children added in v0.6.0

func (o ParticleEmitterNode) Children() []Object

func (*ParticleEmitterNode) Layer added in v0.6.0

func (n *ParticleEmitterNode) Layer() Layer

func (*ParticleEmitterNode) ParticleEmitter added in v0.6.0

func (n *ParticleEmitterNode) ParticleEmitter() *graphics.ParticleEmitter

func (ParticleEmitterNode) RemoveChild added in v0.6.0

func (o ParticleEmitterNode) RemoveChild(child Object)

func (*ParticleEmitterNode) SetLayer added in v0.6.0

func (n *ParticleEmitterNode) SetLayer(l Layer)

func (*ParticleEmitterNode) SetZIndex added in v0.6.0

func (n *ParticleEmitterNode) SetZIndex(index int64)

func (*ParticleEmitterNode) ZIndex added in v0.6.0

func (n *ParticleEmitterNode) ZIndex() int64

type ProgrammableDrawTargetInput added in v0.7.2

type ProgrammableDrawTargetInput struct {
	DrawImage    func(image *ebiten.Image, opt *ebiten.DrawImageOptions, mask core.DrawMask, camG ebiten.GeoM)
	DrawFrame    func(screen *ebiten.Image)
	PrepareFrame func(screen *ebiten.Image)
	Image        func() *ebiten.Image
	Size         func() geom.Vec
}

type Scene added in v0.6.1

type Scene interface {
	Name() string
	Unload() chan struct{}
}

type SceneBase added in v0.6.1

type SceneBase struct {
	Engine    Engine
	Container io.Container
}

func (*SceneBase) Destroy added in v0.6.1

func (s *SceneBase) Destroy()

func (*SceneBase) Setup added in v0.6.1

func (s *SceneBase) Setup(engine Engine)

type ScreenCopyRequest added in v0.7.2

type ScreenCopyRequest interface {
	Done() <-chan struct{}
	ScreenCopy() *ebiten.Image
}

type SpriteNode added in v0.5.0

type SpriteNode struct {
	*Node
	// contains filtered or unexported fields
}

func NewChildSpriteNode added in v0.5.0

func NewChildSpriteNode(parent ObjectContainer, layer Layer) *SpriteNode

func NewRootSpriteNode added in v0.5.0

func NewRootSpriteNode(w World, layer Layer) *SpriteNode

func (SpriteNode) AddChild added in v0.5.0

func (o SpriteNode) AddChild(child Object)

func (SpriteNode) Children added in v0.5.0

func (o SpriteNode) Children() []Object

func (*SpriteNode) Layer added in v0.5.0

func (n *SpriteNode) Layer() Layer

func (SpriteNode) RemoveChild added in v0.5.0

func (o SpriteNode) RemoveChild(child Object)

func (*SpriteNode) SetLayer added in v0.5.0

func (n *SpriteNode) SetLayer(l Layer)

func (*SpriteNode) SetZIndex added in v0.5.0

func (n *SpriteNode) SetZIndex(index int64)

func (*SpriteNode) Sprite added in v0.5.0

func (n *SpriteNode) Sprite() *graphics.Sprite

func (*SpriteNode) ZIndex added in v0.5.0

func (n *SpriteNode) ZIndex() int64

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 TileSetNode added in v0.5.0

type TileSetNode struct {
	*Node
	// contains filtered or unexported fields
}

func NewChildTileSetNode added in v0.5.0

func NewChildTileSetNode(parent ObjectContainer, layer Layer, db []*ebiten.Image, rows, cols int, cellwidthpx, cellheightpx float64, cells []int) *TileSetNode

func NewRootTileSetNode added in v0.5.0

func NewRootTileSetNode(w World, layer Layer, db []*ebiten.Image, rows, cols int, cellwidthpx, cellheightpx float64, cells []int) *TileSetNode

func (TileSetNode) AddChild added in v0.5.0

func (o TileSetNode) AddChild(child Object)

func (TileSetNode) Children added in v0.5.0

func (o TileSetNode) Children() []Object

func (*TileSetNode) Layer added in v0.5.0

func (n *TileSetNode) Layer() Layer

func (TileSetNode) RemoveChild added in v0.5.0

func (o TileSetNode) RemoveChild(child Object)

func (*TileSetNode) SetLayer added in v0.5.0

func (n *TileSetNode) SetLayer(l Layer)

func (*TileSetNode) SetZIndex added in v0.5.0

func (n *TileSetNode) SetZIndex(index int64)

func (*TileSetNode) TileSet added in v0.5.0

func (n *TileSetNode) TileSet() *graphics.TileSet

func (*TileSetNode) ZIndex added in v0.5.0

func (n *TileSetNode) ZIndex() int64

type TransformGetter added in v0.3.0

type TransformGetter interface {
	Entity() ecs.Entity
	Transform() *components.Transform
}

type World added in v0.5.0

type World = core.World

Directories

Path Synopsis
cmd
Package core contains lower level component systems.
Package core contains lower level component systems.
js
Package dom provides methods and structs to construct and manipulate a simple Document Object Model
Package dom provides methods and structs to construct and manipulate a simple Document Object Model
Package easing contains easing functions.
Package easing contains easing functions.
examples
layers/res
Code generated by broccoli at 2020-07-23T07:20:37-03:00.
Code generated by broccoli at 2020-07-23T07:20:37-03:00.
internal
z
io
os
pb
Package modules contains optional parts of the Primen engine.
Package modules contains optional parts of the Primen engine.
Package rx holds default resources for Primen
Package rx holds default resources for Primen

Jump to

Keyboard shortcuts

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