Skip to content

Commit

Permalink
Orbital camera moves on scroll instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhonnyg committed Apr 29, 2023
1 parent 2c94088 commit 13d29e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
8 changes: 8 additions & 0 deletions vantage/vantage.input_binding
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ mouse_trigger {
input: MOUSE_BUTTON_3
action: "VANTAGE_MOUSE_3"
}
mouse_trigger {
input: MOUSE_WHEEL_UP
action: "VANTAGE_WHEEL_UP"
}
mouse_trigger {
input: MOUSE_WHEEL_DOWN
action: "VANTAGE_WHEEL_DOWN"
}
28 changes: 16 additions & 12 deletions vantage/vantage_core.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
local M = {}

M.VANTAGE_W = hash("VANTAGE_W")
M.VANTAGE_S = hash("VANTAGE_S")
M.VANTAGE_A = hash("VANTAGE_A")
M.VANTAGE_D = hash("VANTAGE_D")
M.VANTAGE_Q = hash("VANTAGE_Q")
M.VANTAGE_E = hash("VANTAGE_E")
M.VANTAGE_MOUSE_1 = hash("VANTAGE_MOUSE_1")
M.VANTAGE_MOUSE_2 = hash("VANTAGE_MOUSE_2")
M.VANTAGE_MOUSE_3 = hash("VANTAGE_MOUSE_3")
M.VANTAGE_W = hash("VANTAGE_W")
M.VANTAGE_S = hash("VANTAGE_S")
M.VANTAGE_A = hash("VANTAGE_A")
M.VANTAGE_D = hash("VANTAGE_D")
M.VANTAGE_Q = hash("VANTAGE_Q")
M.VANTAGE_E = hash("VANTAGE_E")
M.VANTAGE_MOUSE_1 = hash("VANTAGE_MOUSE_1")
M.VANTAGE_MOUSE_2 = hash("VANTAGE_MOUSE_2")
M.VANTAGE_MOUSE_3 = hash("VANTAGE_MOUSE_3")
M.VANTAGE_WHEEL_UP = hash("VANTAGE_WHEEL_UP")
M.VANTAGE_WHEEL_DOWN = hash("VANTAGE_WHEEL_DOWN")

M.VANTAGE_TYPE_WASD = 0
M.VANTAGE_TYPE_ORBITAL = 1
Expand Down Expand Up @@ -98,11 +100,13 @@ M.orbital = {
go.set_position(camera_position, main_camera)
go.set_rotation(camera_rot, self.id)
end,
on_input = function(self, action_id, action)
on_input = function(self, action_id, action)
if action_id == hash(M.VANTAGE_MOUSE_1) then
rotate(self, action.dx, action.dy)
elseif action_id == hash(M.VANTAGE_MOUSE_2) then
self.zoom_offset = self.zoom_offset + action.dy * self.movement_speed
elseif action_id == hash(M.VANTAGE_WHEEL_UP) then
self.zoom_offset = self.zoom_offset - self.movement_speed
elseif action_id == hash(M.VANTAGE_WHEEL_DOWN) then
self.zoom_offset = self.zoom_offset + self.movement_speed
end
end
}
Expand Down

0 comments on commit 13d29e1

Please sign in to comment.