Sha256: b8467288a98b6d59168a28103f0eb061e7b86f05bfabde0411fb46aa81013fe9

Contents?: true

Size: 472 Bytes

Versions: 7

Compression:

Stored size: 472 Bytes

Contents

module Draggable
  def drag
    mouse_position = Global.mouse_position

    if @draggable_on_debug && !@dragging && Gosu.button_down?(Gosu::MS_LEFT) && Utils.collision_at?(self, mouse_position.x, mouse_position.y)
      @dragging = true
      @dragging_offset = mouse_position - @position
    end

    if @dragging && !Gosu.button_down?(Gosu::MS_LEFT)
      @dragging = false
    end

    if @dragging
      @position = mouse_position - @dragging_offset
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fantasy-0.1.13 lib/fantasy/draggable.rb
fantasy-0.1.11 lib/fantasy/draggable.rb
fantasy-0.1.9 lib/fantasy/draggable.rb
fantasy-0.1.7 lib/fantasy/draggable.rb
fantasy-0.1.5.1 lib/fantasy/draggable.rb
fantasy-0.1.5 lib/fantasy/draggable.rb
fantasy-0.1.3 lib/fantasy/draggable.rb