module SpaceInvaders::Collideable

Public Instance Methods

collides_with?(bullets) click to toggle source
# File lib/space_invaders/behaviors/collideable.rb, line 3
def collides_with?(bullets)
  bullets.each do |bullet|
    if got_hit_by? bullet
      bullet.delete
      return true
    end
  end
  return false
end
got_hit_by?(bullet) click to toggle source
# File lib/space_invaders/behaviors/collideable.rb, line 13
def got_hit_by?(bullet)
  bullet.x_position.between?(x_position, x_position + width) and
  bullet.y_position.between?(y_position, y_position + height)
end