class Entity::Teleporter
Public Instance Methods
destroy!()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 32 def destroy! space.possessions(self).each {|p| space.doom p} end
draw_zorder()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 38 def draw_zorder; ZOrder::Teleporter end
image_filename()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 36 def image_filename; "tele.gif"; end
should_fall?()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 7 def should_fall?; false; end
teleportable?()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 9 def teleportable?; false; end
to_s()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 40 def to_s return "#{super} [not in a space]" unless space destinations = space.possessions(self).collect do |d| "#{d.x}x#{d.y}" end.join(', ') "#{super} => [#{destinations}]" end
update()
click to toggle source
# File lib/game_2d/entity/teleporter.rb, line 11 def update space.entities_overlapping(x, y).each do |overlap| next unless overlap.teleportable? next if (overlap.x - x).abs > WIDTH/2 next if (overlap.y - y).abs > HEIGHT/2 dest = space.possessions(self) case dest.size when 1 then dest = dest.first if overlap.entities_obstructing(dest.x, dest.y).empty? overlap.warp(dest.x, dest.y) overlap.wake! end when 0 then warn "#{self}: No destination" else warn "#{self}: Multiple destinations: #{dest.inspect}" end end end