Sha256: 12899947e3f9fa8844ccac641a25f08a505266230edaef2591fa3ac6226ef954
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# -*- coding: utf-8 -*- class Missile < Actor #include Wireframe use_systems :steering, :animation, :interpolation collides_as :missile def initialize(opts={}) super activate(:seek) @last_distance_to_target = nil @target = nil set_image('missile-med.png', opts) @z = ZOrder::Missile #build_wireframe Shape.points[:missile] end def save_init_pos @init_x = x @init_y = y end def align_to target to_target = target - pos self.heading = to_target.normalize! end def update @last_distance_to_target = distance_to_target if @target super # If missile goes past target or is 10 pixels away from it, just die if @target && (distance_to_target < 10 || !facing_target?) die end end def draw super color = @color.dup color.saturation = color.value = 0.3 #$lotu.draw_line(@pos.x, @pos.y, color, @target.x, @target.y, color) if @target $lotu.draw_line(@pos.x, @pos.y, color, @init_x, @init_y, color) if @target end def collision_radius @width/2 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
missile-command-ruby-0.0.8 | lib/missile.rb |