You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.1 KiB

Package gohan provides an Entity Component System framework for Ebitengine.
An example game is available at /examples/twinstick, which may be built by
executing the following command (in /examples/twinstick):
go build -tags example .
A general-purpose object, which consists of a unique ID, starting with 1.
The raw data for one aspect of an object, and how it interacts with the world.
Each component is assigned a unique ID, starting with 1.
type ExampleComponent struct {
X, Y float64
Each system runs continuously, performing actions on every entity that matches
each systems' set of required components. When no required components are
specified, the system will match all active entities.
type ExampleSystem struct {
Position *component.PositionComponent // Required component.
Velocity *component.VelocityComponent // Required component.
Sprite *component.SpriteComponent `gohan:"?"` // Optional component.
Enabled bool `gohan:"-"` // Not a component.
Component Design Guidelines
Components are located in a separate package, typically named component. They
should be public (start with an uppercase letter) and may be of any type.
Using only struct types (with zero or more public fields) and accessing the
structs via pointer is recommended. Components should not have any logic (i.e. game code)
within them, as all logic should be implemented within a system.
System Design Guidelines
Systems are located in a separate package, typically named system. They should
be public (start with an uppercase letter) and offer an instantiation function
named as follows: NewSystemNameHere(). Data should be stored within components
attached to one or more entities, rather than within the systems themselves.
References to components must not be maintained outside each Update and Draw
call, or else the application will encounter race conditions.
Environment Variables
Running an application with the environment variable GOHAN_DEBUG set to 1
will enable printing verbose system update and draw information.
package gohan