engine

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: CC0-1.0, MIT Imports: 5 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGame

func NewGame(first Scene) ebiten.Game

NewGame creates world and returns ebiten.Game, which you can use right away, or embed in your own ebiten.Game implementation if you want to add your own behavior there (for example, change the logical resolution which is same as physical by default).

Types

type Entity

type Entity interface {
	ID() int                       // Gets entity id for storage elsewhere.
	Get(components ...interface{}) // Gets entity components, takes a set of pointers to pointers.
}

Entity represents any game object with inner id.

type Scene

type Scene interface {
	Setup(w World)
}

Scene represents the state of the game with a specific set of components, entities and systems. Scenes made in order to implement different game screens: world, pause, settings, menu.

type SystemDrawer

type SystemDrawer interface {
	Draw(w World, screen *ebiten.Image) // Draws specific set of entities.
}

SystemDrawer is a system that draws something every game frame.

type SystemUpdater

type SystemUpdater interface {
	Update(w World) // Updates specific set of entities.
}

SystemUpdater is a system that updates something every game tick.

type View

type View interface {
	Each(consumer func(e Entity)) // Iterates all entities containing the given components.
	Filter() []Entity             // Returns a list of entities containing the given components.
	Get() (e Entity, ok bool)     // Returns the first entity containing the given components and a search status.
}

View is a request to the game world to independently filter entities by their components instead of specifying them in the system. This is useful when you need to make requests to different sets of components in the same system.

type World

type World interface {
	ChangeScene(next Scene)                  // Switch scenes.
	Bounds() image.Rectangle                 // Returns current physical window size.
	View(components ...interface{}) View     // Creates a query to filter entities by their components.
	AddComponents(components ...interface{}) // Registers the used components of your object properties.
	AddSystems(systems ...interface{})       // Adds a system that will work with each entity by its components.
	AddEntities(entities ...interface{})     // Adds an entities that will represent your objects.
	RemoveEntity(entity Entity)              // Removes an entity.
	GetEntity(id int) (e Entity, ok bool)    // Returns an entity by id and a search status.
	Components() int                         // Get current amount of registered components.
	Systems() int                            // Get current amount of added systems.
	Entities() int                           // Get current amount of added entities.
}

World is the main interface of the framework, which implements work with entities, components and systems, allows you to change scenes during the game, as well as create your own queries for entities.

Jump to

Keyboard shortcuts

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