Exemplo n.º 1
0
func moveCamera(camera *trace.FreeFlightCamera, dtf float32) {
	state := sdl.GetKeyboardState()
	switch {
	case state[sdl.GetScancodeFromKey(sdl.K_UP)] != 0:
		camera.YRot += dtf * cameraSpeed
	case state[sdl.GetScancodeFromKey(sdl.K_DOWN)] != 0:
		camera.YRot -= dtf * cameraSpeed
	case state[sdl.GetScancodeFromKey(sdl.K_LEFT)] != 0:
		camera.XRot += dtf * cameraSpeed
	case state[sdl.GetScancodeFromKey(sdl.K_RIGHT)] != 0:
		camera.XRot -= dtf * cameraSpeed
	case state[sdl.GetScancodeFromKey(sdl.K_w)] != 0:
		camera.Move(dtf * cameraSpeed)
	case state[sdl.GetScancodeFromKey(sdl.K_s)] != 0:
		camera.Move(dtf * -cameraSpeed)
	case state[sdl.GetScancodeFromKey(sdl.K_a)] != 0:
		camera.Strafe(dtf * cameraSpeed)
	case state[sdl.GetScancodeFromKey(sdl.K_d)] != 0:
		camera.Strafe(dtf * -cameraSpeed)
	case state[sdl.GetScancodeFromKey(sdl.K_e)] != 0:
		camera.Lift(dtf * cameraSpeed)
	case state[sdl.GetScancodeFromKey(sdl.K_q)] != 0:
		camera.Lift(dtf * -cameraSpeed)
	}
}
Exemplo n.º 2
0
// GetScancodeFromKey translates a key to scancode.
func GetScancodeFromKey(key Key) Scancode {
	return Scancode(sdl.GetScancodeFromKey(sdl.Keycode(key)))
}
Exemplo n.º 3
0
Arquivo: input.go Projeto: fmd/gogol
func (i *Input) handleKeyUpEvent(e *sdl.KeyUpEvent) {
	code := sdl.GetScancodeFromKey(e.Keysym.Sym)
	if i.oldKeyStates[code] == 1 {
		i.KeyUpHandlers.trigger(KeyCode(code))
	}
}