コード例 #1
0
func (self *Keyboard) registerNewEvents(key KeyCode, event events.Event) {
	eventsFromKey, eventFound := self.keyToEvent[key]
	if eventFound {
		for _, eventFromKey := range eventsFromKey {
			event.EventType = eventFromKey
			self.eventReceived(event)
		}
	}
}
コード例 #2
0
ファイル: mouse.go プロジェクト: jasonroelofs/slartibartfast
func (self *Mouse) registerNewEvents(button MouseButtonCode, event events.Event) {
	eventsFromButton, eventFound := self.buttonToEvent[button]
	if eventFound {
		for _, eventFromButton := range eventsFromButton {
			event.EventType = eventFromButton
			self.eventReceived(event)
		}
	}
}
コード例 #3
0
func Test_Turning(t *testing.T) {
	event := events.Event{}

	for _, testValue := range turnTests {
		entity := core.NewEntity()
		transform := components.GetTransform(entity)

		// Set on pressed
		event.Pressed = true

		FPSMapping[testValue.event](entity, event)
		assert.Equal(t, testValue.expectedDir, transform.RotateDir())

		// And undo the change on key release
		event.Pressed = false

		FPSMapping[testValue.event](entity, event)
		assert.Equal(t, math3d.Vector{0, 0, 0}, transform.RotateDir())
	}
}
コード例 #4
0
func Test_FixedCamera_CardinalMovement(t *testing.T) {
	event := events.Event{}

	for _, testValue := range panningCardinalTests {
		entity := core.NewEntity()
		transform := components.GetTransform(entity)

		// Set on pressed
		event.Pressed = true

		FixedCameraMapping[testValue.event](entity, event)
		assert.Equal(t, testValue.expectedDir, transform.MoveDir())

		// And undo the change on key release
		event.Pressed = false

		FixedCameraMapping[testValue.event](entity, event)
		assert.Equal(t, math3d.Vector{0, 0, 0}, transform.MoveDir())
	}
}