gohan/doc.go

59 lines
2.0 KiB
Go

/*
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 .
Entity
A general-purpose object, which consists of a unique ID, starting with 1.
Component
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
}
System
Each system runs continuously, performing actions on every entity that fits
each systems' set of required matching components.
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