lib/demiurge/tmx.rb
# Determine whether this coordinate location can accommodate a
# rectangular item of the given coordinate dimensions.
#
# @since 0.2.0
Determine whether this coordinate location can accommodate a
rectangular item of the given coordinate dimensions.
Determine whether this coordinate location can accommodate a rectangular item of the given coordinate dimensions .
def can_accomodate_dimensions?(left_x, upper_y, width, height)
      return false if left_x < 0 || upper_y < 0
      right_x = left_x + width - 1
      lower_y = upper_y + height - 1
      return false if right_x >= tile_cache_entry["width"] || lower_y >= tile_cache_entry["height"]
      return true unless tile_cache_entry["collision"]
      (left_x..right_x).each do |x|
        (upper_y..lower_y).each do |y|
          return false if tile_cache_entry["collision"][y * tile_cache_entry["width"] + x] != 0
        end
      end
      return true
    end
def can_accomodate_dimensions? ( left_x , upper_y , width , height ) return false if left_x < 0 || upper_y < 0 right_x = left_x + width - 1 lower_y = upper_y + height - 1 return false if right_x >= tile_cache_entry [ "width" ] || lower_y >= tile_cache_entry [ "height" ] return true unless tile_cache_entry [ "collision" ] ( left_x .. right_x ) . each do | x | ( upper_y .. lower_y ) . each do | y | return false if tile_cache_entry [ "collision" ] [ y * tile_cache_entry [ "width" ] + x ] != 0 end end return true end
Determine whether this coordinate location can accommodate a
rectangular item of the given coordinate dimensions.
Determine whether this coordinate location can accommodate a rectangular item of the given coordinate dimensions .
left_x
upper_y
width
height
since
None