Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ecs package #80

Merged
merged 1 commit into from
Nov 6, 2022
Merged

update ecs package #80

merged 1 commit into from
Nov 6, 2022

Conversation

yohamta
Copy link
Owner

@yohamta yohamta commented Nov 6, 2022

Simplify the API.

Example:

func NewGame() *Game {
	// ...
	g.ecs.
		// Systems
		AddSystem(system.NewSpawn().Update).
		AddSystem(metrics.Update).
		AddSystem(system.NewBounce(&g.bounds).Update).
		AddSystem(system.Velocity.Update).
		AddSystem(system.Gravity.Update).
		// Renderers
		AddRenderer(layers.LayerBackground, system.DrawBackground).
		AddRenderer(layers.LayerMetrics, metrics.Draw).
		AddRenderer(layers.LayerBunnies, system.Render.Draw)
}

func (g *Game) Update() error {
	g.ecs.Update()
	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
	screen.Clear()
	g.ecs.DrawLayer(layers.LayerBackground, screen)
	g.ecs.DrawLayer(layers.LayerBunnies, screen)
	g.ecs.DrawLayer(layers.LayerMetrics, screen)
}

@yohamta yohamta merged commit e67fd23 into main Nov 6, 2022
@yohamta yohamta deleted the update-ecs branch November 6, 2022 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant