Okay, so I wrote a script that'll allow the game player to jump with the
touch of a button. This script, I wanted a method that'll adjust the
distance in which
the game player jumps, based on the farthest passible tile. To define
the method, I used a 'for i' statement with 0 to the max distance, for
each passible 'space' he can jump, I push the value into an array named
'@spaces', respectively.

[code]  def jump_dist
    @spaces = []
    case @direction
    when 2 # Down
      for i in 0...Jump::Distance
        if passable?(self.x, self.y + i, 2)
          @spaces[i] = i
          return @spaces if i == Jump::Distance
        end
      end
    when 4 # Left
      for i in 0...Jump::Distance
        if passable?(self.x - i, self.y, 4)
          @spaces[i] = i
          return @spaces if i == Jump::Distance
        end
      end
    when 6 # Right
      for i in 0...Jump::Distance
        if passable?(self.x + i, self.y, 6)
          @spaces[i] = i
          return @spaces if i == Jump::Distance
        end
      end
    when 8 # Up
      for i in 0...Jump::Distance
        if passable?(self.x, self.y - i, 8)
          @spaces[i] = i
          return @spaces if i == Jump::Distance
        end
      end
    end
  end[/code]

...Maybe I wrote that a little oddly, correct me if you know a better
functional method.

Anyways, next I test it with 'print(jump_dist)' whenever the player
'jumps' and it returns 0...3 (3 is Jump::Distance, BTW)

So basically, instead of returning an array, it returns a Range.

How do I get this to return me an array of only passable 'spaces', and
secondly how do I pull the highest value out of that array?
-- 
Posted via http://www.ruby-forum.com/.