Documentation ¶
Overview ¶
components.go
systems.go
Index ¶
- Constants
- func DrawCircleOutline(screen *ebiten.Image, centerX, centerY, radius float64, clr color.Color)
- func GetComponent[T any](entity *Entity, componentType ComponentType) (*T, bool)
- type Component
- type ComponentType
- type Entity
- type EntityManager
- type Game
- type GraphicsComponent
- type OrbitComponent
- type OrbitalSystem
- type PositionComponent
- type RenderSystem
- type System
Constants ¶
const ( ScreenWidth = 480 ScreenHeight = 640 )
Variables ¶
This section is empty.
Functions ¶
func DrawCircleOutline ¶
func GetComponent ¶
func GetComponent[T any](entity *Entity, componentType ComponentType) (*T, bool)
Types ¶
type Component ¶
type Component interface {
ComponentType() ComponentType
}
Component represents a generic component.
type ComponentType ¶
type ComponentType int
ComponentType represents the type of a component.
const ( Graphics ComponentType = iota Orbit Position )
type Entity ¶
type Entity struct { Tag string Enabled bool Components map[ComponentType]interface{} }
Entity represents an entity in the ECS system.
func (*Entity) AddComponent ¶
AddComponent adds a component to an entity.
type EntityManager ¶
type EntityManager struct {
// contains filtered or unexported fields
}
EntityManager manages entities in the ECS system.
func (*EntityManager) AddEntity ¶
func (em *EntityManager) AddEntity(entity *Entity)
AddEntity adds a new entity to the ECS system.
func (*EntityManager) AddSystem ¶
func (em *EntityManager) AddSystem(system System)
AddSystem adds a new system to the ECS.
func (*EntityManager) UpdateSystems ¶
func (em *EntityManager) UpdateSystems()
UpdateSystems updates all systems in the ECS.
type GraphicsComponent ¶
GraphicsComponent holds data related to rendering.
func (*GraphicsComponent) ComponentType ¶
func (c *GraphicsComponent) ComponentType() ComponentType
type OrbitComponent ¶
OrbitComponent contains data on the orbit of the planet.
func (*OrbitComponent) ComponentType ¶
func (c *OrbitComponent) ComponentType() ComponentType
type OrbitalSystem ¶
type OrbitalSystem struct{}
OrbitalSystem updates the position of the components based on the orbit data.
func (*OrbitalSystem) Update ¶
func (os *OrbitalSystem) Update(entity *Entity)
Update implements the logic to update the orbital system.
type PositionComponent ¶
type PositionComponent struct {
X, Y float64
}
PositionComponent holds data on the current position of the planet.
func (*PositionComponent) ComponentType ¶
func (c *PositionComponent) ComponentType() ComponentType
type RenderSystem ¶
type RenderSystem struct{}
RenderSystem renders the screen.
func (*RenderSystem) Draw ¶
func (rs *RenderSystem) Draw(screen *ebiten.Image, entity *Entity)
func (*RenderSystem) Update ¶
func (rs *RenderSystem) Update(entity *Entity)
Update implements the logic to update the render system.