Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic zoom #6

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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