MCPcopy
hub / github.com/EngoEngine/engo / New

Method New

demos/pong/pong.go:191–205  ·  view source on GitHub ↗
(*ecs.World)

Source from the content-addressed store, hash-verified

189}
190
191func (s *SpeedSystem) New(*ecs.World) {
192 engo.Mailbox.Listen("CollisionMessage", func(message engo.Message) {
193 log.Println("collision")
194
195 collision, isCollision := message.(common.CollisionMessage)
196 if isCollision {
197 // See if we also have that Entity, and if so, change the speed
198 for _, e := range s.entities {
199 if e.ID() == collision.Entity.BasicEntity.ID() {
200 e.SpeedComponent.X *= -1
201 }
202 }
203 }
204 })
205}
206
207func (s *SpeedSystem) Add(basic *ecs.BasicEntity, speed *SpeedComponent, space *common.SpaceComponent) {
208 s.entities = append(s.entities, speedEntity{basic, speed, space})

Callers

nothing calls this directly

Calls 2

ListenMethod · 0.80
IDMethod · 0.80

Tested by

no test coverage detected