class Gosu::BlockAllocator::Impl

Public Class Methods

new(*args) click to toggle source
# File lib/gosu_android/graphics/blockAllocator.rb, line 7
def initialize(*args)      
  old_initialize *args
  if self[:blocks] == nil
    self[:blocks] = Array.new
  end  
end
Also aliased as: old_initialize

Public Instance Methods

is_block_free(block) click to toggle source
# File lib/gosu_android/graphics/blockAllocator.rb, line 23
def is_block_free(block)
  #(The right-th column and the bottom-th row are outside of the block.)
  right = block.left + block.width
  bottom = block.top + block.height

  #Block isn't valid.
  if (right > self[:width] || bottom > self[:height])
      return false
  end
  
  #Test if the block collides with any existing rects.
  self[:blocks].each do |i|
      if (i.left < right and block.left < i.left + i.width and
          i.top < bottom and block.top < i.top + i.height)
          return false
      end
  end
  true  
end
mark_block_used(block, a_width, a_height) click to toggle source
# File lib/gosu_android/graphics/blockAllocator.rb, line 14
def mark_block_used(block, a_width, a_height)
  self[:first_x] += a_width
  if (self[:first_x] + a_width) >= self[:width]
    self[:first_x] = 0
    self[:first_y] += a_height
  end
  self[:blocks].push block     
end
old_initialize(*args)
Alias for: new