Documentation ¶
Index ¶
Constants ¶
const ( // LogTypeDebug is debug log message type. LogTypeDebug = iota // LogTypeError is error log message type. LogTypeError = iota )
Variables ¶
This section is empty.
Functions ¶
func FreeSystem ¶
func FreeSystem(entities []Entity)
FreeSystem deallocated and destroys everything.
func RenderSystem ¶
RenderSystem is an ECS system that renders SpriteComponents.
Types ¶
type Entity ¶
type Entity struct { SpriteComponent *SpriteComponent TransformComponent *TransformComponent }
Entity is simply a collection of ECS components.
type EntityBuilder ¶
type EntityBuilder struct {
// contains filtered or unexported fields
}
EntityBuilder is a helper struct that builds entities
func NewEntityBuilder ¶
func NewEntityBuilder() EntityBuilder
NewEntityBuilder makes a new instance of EntityBuilder.
func (EntityBuilder) AddSprite ¶
func (entityBuilder EntityBuilder) AddSprite(sprite *SpriteComponent) EntityBuilder
AddSprite adds sprite to building entity.
func (EntityBuilder) Build ¶
func (entityBuilder EntityBuilder) Build() Entity
Build is a final method to call and it returns built entity.
func (EntityBuilder) SetLocation ¶
func (entityBuilder EntityBuilder) SetLocation(x int32, y int32) EntityBuilder
SetLocation sets location of the sprite using x and y coordinates.
type EntityManager ¶
type EntityManager struct {
// contains filtered or unexported fields
}
EntityManager is a helper struct that manages all entities.
func NewEntityManager ¶
func NewEntityManager() EntityManager
NewEntityManager makes a new instance of EntityManager.
func (*EntityManager) AddEntity ¶
func (entityManager *EntityManager) AddEntity(entity Entity)
AddEntity adds entity into the list.
func (*EntityManager) GetEntities ¶
func (entityManager *EntityManager) GetEntities() []Entity
GetEntities retrieves entities from EntityManager.
type Resource ¶
type Resource interface {
GetResourceFilename() string
}
Resource is an interface that all resources must implement.
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager is a struct that manages all your game resources, like sprites, audio files, etc.
func NewResourceManager ¶
func NewResourceManager() ResourceManager
NewResourceManager makes new instance of ResourceManager.
func (*ResourceManager) AddResources ¶
func (resourceManager *ResourceManager) AddResources(renderer *sdl.Renderer, files []string)
AddResources takes filenames as an input and loads resources into memory.
type SpriteComponent ¶
type SpriteComponent struct { Texture *sdl.Texture W int32 H int32 // contains filtered or unexported fields }
SpriteComponent is an ECS component and resource that stores sprite of the entity.
func NewSpriteComponent ¶
func NewSpriteComponent(renderer *sdl.Renderer, file string) (*SpriteComponent, error)
NewSpriteComponent makes a new instance of SpriteComponent by reading the BMP file.
func (SpriteComponent) GetResourceFilename ¶
func (spriteComponent SpriteComponent) GetResourceFilename() string
GetResourceFilename returns the filename of sprite.
type TransformComponent ¶
TransformComponent is an ECS component that stores location of the entity.
func NewTransformComponent ¶
func NewTransformComponent(x int32, y int32) *TransformComponent
NewTransformComponent makes new instance of TransformComponent.