class Entity::Hole

Public Instance Methods

apply_gravity_to?(entity) click to toggle source
# File lib/game_2d/entity/hole.rb, line 8
def apply_gravity_to?(entity)
  distance = space.distance_between(cx, cy, entity.cx, entity.cy)
  entity.harmed_by(self, (400 - distance).ceil) if distance < 400
  force = 10000000.0 / (distance**2)
  return true if force > 200.0
  return false if force < 1.0
  # We could use trig here -- but we have a shortcut.
  # We know the X/Y proportions of the force must be
  # the same as the X/Y proportions of the distance.
  delta_x = cx - entity.cx
  delta_y = cy - entity.cy
  force_x = force * (delta_x / distance)
  force_y = force * (delta_y / distance)
  entity.accelerate(force_x.truncate, force_y.truncate)
  true
end
draw_zorder() click to toggle source
# File lib/game_2d/entity/hole.rb, line 29
def draw_zorder; ZOrder::Teleporter end
image_filename() click to toggle source
# File lib/game_2d/entity/hole.rb, line 27
def image_filename; "hole.png"; end
should_fall?() click to toggle source
# File lib/game_2d/entity/hole.rb, line 6
def should_fall?; false; end
update() click to toggle source
# File lib/game_2d/entity/hole.rb, line 25
def update; end