lib/minigl/movement.rb
def move_free(aim, speed)
      if aim.is_a? Vector
        x_d = aim.x - @x; y_d = aim.y - @y
        distance = Math.sqrt(x_d**2 + y_d**2)

        if distance == 0
          @speed.x = @speed.y = 0
          return
        end

        @speed.x = 1.0 * x_d * speed / distance
        @speed.y = 1.0 * y_d * speed / distance

        if (@speed.x < 0 and @x + @speed.x <= aim.x) or (@speed.x >= 0 and @x + @speed.x >= aim.x)
          @x = aim.x
          @speed.x = 0
        else
          @x += @speed.x
        end

        if (@speed.y < 0 and @y + @speed.y <= aim.y) or (@speed.y >= 0 and @y + @speed.y >= aim.y)
          @y = aim.y
          @speed.y = 0
        else
          @y += @speed.y
        end
      else
        rads = aim * Math::PI / 180
        @speed.x = speed * Math.cos(rads)
        @speed.y = speed * Math.sin(rads)
        @x += @speed.x
        @y += @speed.y
      end
    end
def move_free(aim, speed)
      if aim.is_a? Vector
        x_d = aim.x - @x; y_d = aim.y - @y
        distance = Math.sqrt(x_d**2 + y_d**2)

        if distance == 0
          @speed.x = @speed.y = 0
          return
        end

        @speed.x = 1.0 * x_d * speed / distance
        @speed.y = 1.0 * y_d * speed / distance

        if (@speed.x < 0 and @x + @speed.x <= aim.x) or (@speed.x >= 0 and @x + @speed.x >= aim.x)
          @x = aim.x
          @speed.x = 0
        else
          @x += @speed.x
        end

        if (@speed.y < 0 and @y + @speed.y <= aim.y) or (@speed.y >= 0 and @y + @speed.y >= aim.y)
          @y = aim.y
          @speed.y = 0
        else
          @y += @speed.y
        end
      else
        rads = aim * Math::PI / 180
        @speed.x = speed * Math.cos(rads)
        @speed.y = speed * Math.sin(rads)
        @x += @speed.x
        @y += @speed.y
      end
    end
Moves this object, without performing any collision checking, towards
 a specified point or in a specified direction.

 Parameters:
 [aim] A +Vector+ specifying where the object will move to or an angle (in
       degrees) indicating the direction of the movement. Angles are
       measured starting from the right (i.e., to move to the right, the
       angle must be 0) and raising clockwise.
 [speed] The constant speed at which the object will move. This must be
         provided as a scalar, not a vector.