Sha256: 3159b9203e81aebe6b0e09c04068361255f4e7e417f57c4d17335a741dce26f6

Contents?: true

Size: 485 Bytes

Versions: 23

Compression:

Stored size: 485 Bytes

Contents

class BoundingBox
  attr_reader :left, :bottom, :width, :height, :right, :top

  def initialize(left, bottom, width, height)
    @left = left
    @bottom = bottom
    @width = width
    @height = height
    @right = @left + @width
    @top = @bottom + @height
  end

  def collide?(x, y)
    x >= left && x <= right && y >= bottom && y <= top
  end

  def intersects?(box)
    self.right > box.left && self.bottom < box.top && self.left < box.right && self.top > box.bottom
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
make_it_so-0.6.0 templates/gosu/lib/bounding_box.rb
make_it_so-0.5.1 templates/gosu/lib/bounding_box.rb
make_it_so-0.5.0 templates/gosu/lib/bounding_box.rb
make_it_so-0.4.5 templates/gosu/lib/bounding_box.rb
make_it_so-0.4.3 templates/gosu/lib/bounding_box.rb
make_it_so-0.4.2 templates/gosu/lib/bounding_box.rb
make_it_so-0.4.1 templates/gosu/lib/bounding_box.rb
make_it_so-0.4.0 templates/gosu/lib/bounding_box.rb
make_it_so-0.3.8 templates/gosu/lib/bounding_box.rb
make_it_so-0.3.7 templates/gosu/lib/bounding_box.rb
make_it_so-0.3.6 templates/gosu/lib/bounding_box.rb
make_it_so-0.3.5 templates/gosu/lib/bounding_box.rb
make_it_so-0.3.4 templates/gosu/lib/bounding_box.rb
make_it_so-0.2.4 templates/gosu/lib/bounding_box.rb
make_it_so-0.2.3 templates/gosu/lib/bounding_box.rb
make_it_so-0.1.4 templates/gosu/lib/bounding_box.rb
make_it_so-0.1.3 templates/gosu/lib/bounding_box.rb
make_it_so-0.1.1 templates/gosu/lib/bounding_box.rb
make_it_so-0.1.0 templates/gosu/lib/bounding_box.rb
make_it_so-0.0.9 templates/gosu/lib/bounding_box.rb