-
Notifications
You must be signed in to change notification settings - Fork 7
Input devices
zeganstyl edited this page Sep 18, 2020
·
1 revision
There is singleton KB for keyboard and MOUSE for mouse device.
Simple input devices event handling:
KB.addListener(object: IKeyListener {
override fun keyDown(keycode: Int) {
if (keycode == KB.SPACE) println("Space pressed")
println("key pressed: $keycode")
}
override fun keyUp(keycode: Int) {
println("key released: $keycode")
}
})
MOUSE.addListener(object: IMouseListener {
override fun buttonDown(button: Int, screenX: Int, screenY: Int, pointer: Int) {
println("button pressed: $button")
}
override fun moved(screenX: Int, screenY: Int) {
println("mouse moved: $screenX, $screenY")
}
})
Here we know when button was pressed/released or mouse moved.
We can check current state of input devices:
// in main loop
if (KB.isKeyPressed(KB.SPACE)) println("Space is pressed")
if (KB.shift) println("Shift is pressed")
println("mouse coords: (${MOUSE.x}, ${MOUSE.y})")
-
Quick Start
-
3D graphics
-
Math