Sha256: 79ea86d4446fe11c296ac9dac633b2979aa73df2c08f91cc13953d3460366875

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require_relative 'projectile.rb'
# Follows targets location only at time of launch. Will not follow target
class SemiGuidedMissile < Projectile
  attr_reader :x, :y, :time_alive, :mouse_start_x, :mouse_start_y, :health
  COOLDOWN_DELAY = 75
  MAX_SPEED      = 30
  STARTING_SPEED = 0.0
  INITIAL_DELAY  = 2
  SPEED_INCREASE_FACTOR = 2
  DAMAGE = 15
  AOE = 0
  
  MAX_CURSOR_FOLLOW = 4
  # ADVANCED_HIT_BOX_DETECTION = true
  ADVANCED_HIT_BOX_DETECTION = false

  def get_image
    # Gosu::Image.new("#{MEDIA_DIRECTORY}/mini_missile_reverse.png")
    Gosu::Image.new("#{MEDIA_DIRECTORY}/tiny_missile.png")
  end

  def initialize(scale, screen_width, screen_height, object, homing_object, angle_min = nil, angle_max = nil, angle_init = nil, options = {})
    options[:relative_object] = object
    super(scale, screen_width, screen_height, object, homing_object.x, homing_object.y, angle_min, angle_max, angle_init, options)
    @health = 5
    # puts "CUSTOM DELAY: #{@custom_initial_delay}"
  end

  def destructable?
    true
  end

  def is_alive
    @health > 0
  end

  def drops
    [
      SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, nil, {ttl: 2, third_scale: true}),
    ]
  end


  def take_damage damage
    @health -= damage
  end


  def update mouse_x = nil, mouse_y = nil
    if is_alive
      super(mouse_x, mouse_y)
    else
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
line-em-up-0.4.0 line-em-up/models/semi_guided_missile.rb