lib/demiurge/tmx.rb
def any_legal_position
      entry = tile_cache_entry
      if entry["collision"]
        # We have a collision layer? Fabulous. Scan upper-left to lower-right until we get something non-collidable.
        (0...entry["width"]).each do |x|
          (0...entry["height"]).each do |y|
            if entry["collision"][y * tile_cache_entry["width"] + x] == 0
              # We found a walkable spot.
              return "#{@name}##{x},#{y}"
            end
          end
        end
        # If we got here, there exists no walkable spot in the whole location.
      end
      # Screw it, just return the upper left corner.
      return "#{@name}#0,0"
    end
# For a TmxLocation's legal position, find somewhere not covered
# as a collision on the collision map.
#
# @return [String] A legal position string within this location
# @since 0.2.0
For a TmxLocation's legal position, find somewhere not covered
as a collision on the collision map.
For a TmxLocation ' s legal position find somewhere not covered as a collision on the collision map .
def any_legal_position
      entry = tile_cache_entry
      if entry["collision"]
        (0...entry["width"]).each do |x|
          (0...entry["height"]).each do |y|
            if entry["collision"][y * tile_cache_entry["width"] + x] == 0
              return "#{@name}##{x},#{y}"
            end
          end
        end
      end
      return "#{@name}#0,0"
    end
def any_legal_position entry = tile_cache_entry if entry [ "collision" ] ( 0 ... entry [ "width" ] ) . each do | x | ( 0 ... entry [ "height" ] ) . each do | y | if entry [ "collision" ] [ y * tile_cache_entry [ "width" ] + x ] == 0 return "#{@name}##{x},#{y}" end end end end return "#{@name}#0,0" end
For a TmxLocation's legal position, find somewhere not covered
as a collision on the collision map.
For a TmxLocation ' s legal position find somewhere not covered as a collision on the collision map .
# We have a collision layer? Fabulous. Scan upper-left to lower-right until we get something non-collidable. # We found a walkable spot. # If we got here, there exists no walkable spot in the whole location. # Screw it, just return the upper left corner.
A legal position string within this location
A legal position string within this location
String
since
None