Skip to content

Commit

Permalink
Merge pull request #6 from yuripourre-forks/zoom
Browse files Browse the repository at this point in the history
Add basic zoom
  • Loading branch information
JamesTKhan authored Apr 12, 2022
2 parents c22dbab + 9761000 commit 19a3537
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class FreeCamController : InputAdapter() {
private val UP = Input.Keys.Q
private val DOWN = Input.Keys.E
private var velocity = SPEED_1
private var zoomAmount = SPEED_01
private var degreesPerPixel = 0.5f
private val tmp = Vector3()

Expand Down Expand Up @@ -90,6 +91,12 @@ class FreeCamController : InputAdapter() {
return false
}

override fun scrolled(amountX: Float, amountY: Float): Boolean {
tmp.set(camera!!.direction).nor().scl(-amountY * zoomAmount)
camera!!.position.add(tmp)
return true
}

@JvmOverloads fun update(deltaTime: Float = Gdx.graphics.deltaTime) {
if (keys.containsKey(FORWARD)) {
tmp.set(camera!!.direction).nor().scl(deltaTime * velocity)
Expand Down

0 comments on commit 19a3537

Please sign in to comment.