Almost have mouse picking working when zoomed

This commit is contained in:
2019-10-01 08:52:12 -05:00
parent 51db2dc5b8
commit a3a2e2a2ac
2 changed files with 6 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ class IMICRTS
end
def mouse_pick(x, y)
mouse = CyberarmEngine::Vector.new(x, y)
mouse = CyberarmEngine::Vector.new(x, y) / @zoom
normalized = (mouse / @zoom - @position / @zoom) * @zoom
normalized.x = normalized.x.floor
@@ -58,6 +58,10 @@ class IMICRTS
(vec1 - vec2) * factor.clamp(0.0, 1.0)
end
def aspect_ratio
window.height / window.width.to_f
end
def move
@velocity.x += @scroll_speed * window.dt if Gosu.button_down?(Gosu::KB_LEFT) || window.mouse_x < 15
@velocity.x -= @scroll_speed * window.dt if Gosu.button_down?(Gosu::KB_RIGHT) || window.mouse_x > window.width - 15