Skip to content

Entity Component System written in Golang using generics

License

Notifications You must be signed in to change notification settings

kaiaverkvist/tinyecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinyecs

Entity Component System written in Golang using generics.

Basic usage

type testEntity struct {
	tinyecs.Entity
}

// Initialize a new instance of the ECS engine.
e := tinyecs.NewEngine()

// Define and set up a new testEntity.
entity := testEntity{}

// Add some components along with passing in the engine instance.
entity.AddComponents(
    &e,
	
    velocity{},
    playerData{name: "test", health: 100.0},
)

// Add the entity to the ECS engine.
e.AddEntity(entity)

// This use of the Each function iterates over all playerdata components
// and prints the name of each of them.
tinyecs.Each[playerData](&e, func(id uint64, obj playerData) {
	log.Println(obj.name)
})

About

Entity Component System written in Golang using generics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages