Skip to content

Commit 9d54c6e

Browse files
committed
feat: F2 for enabling debug camera controller
1 parent aeeca33 commit 9d54c6e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cake/core/src/main/java/org/demoth/cake/stages/Game3dScreen.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ class Game3dScreen : KtxScreen, InputProcessor, ServerMessageProcessor {
274274
if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
275275
cmd.buttons = cmd.buttons or BUTTON_ATTACK.toByte()
276276
}
277-
278277
if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
279278
cmd.forwardmove = 100
280279
}
@@ -716,8 +715,12 @@ class Game3dScreen : KtxScreen, InputProcessor, ServerMessageProcessor {
716715
}
717716
}
718717

719-
// client only movement: temporary
718+
// todo: extract into separate class
720719
override fun keyDown(keycode: Int): Boolean {
720+
// toggle debug (fly) camera controller
721+
if (keycode == Input.Keys.F2) {
722+
cameraInputController.enabled = !cameraInputController.enabled
723+
}
721724
return cameraInputController.keyDown(keycode)
722725
}
723726

cake/core/src/main/kotlin/org/demoth/cake/clientcommon/FlyingCameraController.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import com.badlogic.gdx.math.Vector3
77

88
class FlyingCameraController(camera: Camera): CameraInputController(camera) {
99
private val right = Vector3()
10+
var enabled = false
1011
val movementDirection = Vector3()
1112

1213
init {
1314
translateUnits = 500f
1415
}
1516

1617
override fun process(deltaX: Float, deltaY: Float, button: Int): Boolean {
18+
if (!enabled) return false
1719
if (button == rotateButton) {
1820
// PITCH: rotate around local "right" axis
1921
right.set(camera.direction).crs(camera.up).nor()
@@ -30,6 +32,7 @@ class FlyingCameraController(camera: Camera): CameraInputController(camera) {
3032
}
3133

3234
override fun update() {
35+
if (!enabled) return
3336
// WASD movement
3437
if (rotateRightPressed || rotateLeftPressed || forwardPressed || backwardPressed) {
3538
movementDirection.set(0f, 0f, 0f)

0 commit comments

Comments
 (0)