mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-13 06:52:33 +00:00
Almost have mouse picking working when zoomed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -63,7 +63,7 @@ class IMICRTS
|
||||
end
|
||||
|
||||
mouse = @camera.mouse_pick(window.mouse_x, window.mouse_y)
|
||||
@mouse_pos.text = "Zoom: #{@camera.zoom}\nX: #{window.mouse_x}\nY: #{window.mouse_y}\n\nX: #{mouse.x}\nY: #{mouse.y}"
|
||||
@mouse_pos.text = "Aspect Ratio: #{@camera.aspect_ratio}\nZoom: #{@camera.zoom}\nX: #{window.mouse_x}\nY: #{window.mouse_y}\n\nX: #{mouse.x}\nY: #{mouse.y}"
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
|
||||
Reference in New Issue
Block a user