func Test_Camera_AddComponent(t *testing.T) {
	camera := NewCamera()
	input := new(components.Input)
	camera.AddComponent(input)

	assert.Equal(t, input, components.GetInput(camera.Entity))
}
Example #2
0
// TearDownEntity :: EntityListener
func (self *Input) TearDownEntity(entity *core.Entity) {
	input := components.GetInput(entity)

	if input.WantsPolling() {
		self.inputQueue.UnpollEvents(input.Polling)
	}
}
Example #3
0
func (self *Input) Update(deltaT float32) {
	var input *components.Input
	nextEvents := self.inputQueue.RecentEvents()

	for _, entity := range self.entitySet.Entities() {
		input = components.GetInput(entity)

		for _, event := range nextEvents {
			if callback, ok := input.Mapping[event.EventType]; ok {
				callback(entity, event)
			}
		}
	}
}
func Test_Player_HasInput(t *testing.T) {
	player := NewPlayer()
	assert.NotNil(t, components.GetInput(player.GetEntity()), "No input component found")
}