From 2a179ed93559f47ae5c1364ad800d9e15d3909b0 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Tue, 8 Oct 2019 09:16:19 -0500 Subject: [PATCH] Disable lerping camera position when dragging with mouse, commented out debugging rects --- lib/camera.rb | 5 +++-- lib/states/game.rb | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/camera.rb b/lib/camera.rb index d1c8724..2883d4b 100644 --- a/lib/camera.rb +++ b/lib/camera.rb @@ -93,7 +93,8 @@ class IMICRTS if @drag_start @velocity *= 0.0 - @position = @position.lerp(@drag_start - window.mouse.clone, @grab_drag / @zoom) + + @position = window.mouse - @drag_start end end @@ -107,7 +108,7 @@ class IMICRTS when Gosu::MS_WHEEL_DOWN @zoom = (@zoom - 0.25).clamp(@min_zoom, @max_zoom) when Gosu::MS_MIDDLE - @drag_start = transform(window.mouse) + @drag_start = window.mouse - @position end end diff --git a/lib/states/game.rb b/lib/states/game.rb index 97bbcd0..032284d 100644 --- a/lib/states/game.rb +++ b/lib/states/game.rb @@ -60,13 +60,14 @@ class IMICRTS @director.entities.each(&:draw) @selected_entities.each(&:selected_draw) - center = @player.camera.center - @player.camera.position - draw_rect(center.x - 10, center.y - 10, 20, 20, Gosu::Color::RED, Float::INFINITY) + # center = @player.camera.center - @player.camera.position + # draw_rect(center.x - 10, center.y - 10, 20, 20, Gosu::Color::RED, Float::INFINITY) - mouse = @player.camera.transform(window.mouse) - draw_rect(mouse.x - 10, mouse.y - 10, 20, 20, Gosu::Color::YELLOW, Float::INFINITY) + # mouse = @player.camera.transform(window.mouse) + # draw_rect(mouse.x - 10, mouse.y - 10, 20, 20, Gosu::Color::YELLOW, Float::INFINITY) - draw_rect(@goal.x - 10, @goal.y - 10, 20, 20, Gosu::Color::WHITE, Float::INFINITY) if @goal + # Goal + # draw_rect(@goal.x - 10, @goal.y - 10, 20, 20, Gosu::Color::WHITE, Float::INFINITY) if @goal Gosu.draw_rect(@box.min.x, @box.min.y, @box.width, @box.height, Gosu::Color.rgba(50, 50, 50, 150), Float::INFINITY) if @box end