class Launcher

Constants

COOLDOWN_DELAY

DAMAGE = 0.001

MAX_SPEED

Friendly projects are + speeds

Attributes

active[RW]
cooldown_wait[RW]
image_path[RW]
inited[RW]
projectiles[RW]
test[RW]
x[RW]
y[RW]

Public Class Methods

get_hardpoint_image() click to toggle source

Used via hardpoint

# File line-em-up/models/launcher.rb, line 38
def self.get_hardpoint_image
  # raise "Override me"
  # default
  Gosu::Image.new("#{MEDIA_DIRECTORY}/laser_beam_hardpoint.png")
end
get_image() click to toggle source

Get image is called before the initialization is complete

# File line-em-up/models/launcher.rb, line 55
def self.get_image
  # optional image
  # Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png")
end
new(scale, screen_width, screen_height, object, options = {}) click to toggle source
Calls superclass method DumbProjectile::new
# File line-em-up/models/launcher.rb, line 19
def initialize(scale, screen_width, screen_height, object, options = {})
  options[:relative_y_padding] = -(object.image_height_half)
  super(scale, screen_width, screen_height, object, options)
  @active = true
  @projectiles = []
  @image_optional = self.class.get_image#Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png")

  @inited = true
  @cooldown_wait = 0
  # @image_angle = options[:image_angle] || 0
  # puts "IMAGE ANGLE: #{@image_angle}"
  # raise "STOP "
end

Public Instance Methods

attack(pointer) click to toggle source
# File line-em-up/models/launcher.rb, line 44
def attack pointer
  if @cooldown_wait <= 0
    options = {damage_increase: @damage_increase}
    projectile = init_projectile(options)
    @projectiles << projectile
    @cooldown_wait = get_cooldown
    return projectile
  end
end
deactivate() click to toggle source
# File line-em-up/models/launcher.rb, line 69
def deactivate
  @active = false
  # @projectiles.each do |particle|
  #   particle.active = false
  # end
end
draw() click to toggle source
  end
end
return last_active_particle

end

# File line-em-up/models/launcher.rb, line 113
def draw
  if @inited
    if @active
      if @image_optional
        # if @image_angle != nil
        #   @image_optional.draw_rot(@x - @image_width_half, @y - @image_height_half, get_draw_ordering, @image_angle, 0.5, 0.5, @scale, @scale)
        # else
          @image_optional.draw(@x - @image_width_half, @y - @image_height_half, get_draw_ordering, @scale, @scale)
        # end
      end
    end

    return true
  else
    return false
  end
end
draw_gl() click to toggle source
# File line-em-up/models/launcher.rb, line 131
def draw_gl
  # if @inited
  #   z = ZOrder::Projectile
  #   new_width1, new_height1, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x - @image_width_half/2, @y - @image_height_half/2, @screen_width         , @screen_height)
  #   new_width2, new_height2, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x, @y + @image_height_half/2, @screen_width         , @screen_height)
  #   new_width3, new_height3, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x + @image_width_half/2, @y - @image_height_half/2, @screen_width         , @screen_height)

  #   glEnable(GL_BLEND)
  #   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

  #   glBegin(GL_TRIANGLES)
  #     glColor4f(0, 1, 0, 0.2)
  #     glVertex3f(new_width1, new_height1, 0.0)
  #     glVertex3f(new_width2, new_height2, 0.0)
  #     glVertex3f(new_width3, new_height3, 0.0)
  #   glEnd
  # end
end
get_cooldown() click to toggle source
# File line-em-up/models/launcher.rb, line 33
def get_cooldown
  COOLDOWN_DELAY
end
get_draw_ordering() click to toggle source
# File line-em-up/models/launcher.rb, line 93
def get_draw_ordering
  ZOrder::Launcher
end
get_hardpoint_image() click to toggle source

In generalobject def get_image

self.class.get_image

end

# File line-em-up/models/launcher.rb, line 64
def get_hardpoint_image
  # default
  Gosu::Image.new("#{MEDIA_DIRECTORY}/hardpoint_empty.png")
end
init_projectile() click to toggle source
# File line-em-up/models/launcher.rb, line 14
def init_projectile
  raise "Override me"
end
update(mouse_x = nil, mouse_y = nil, object = nil, scroll_factor = 1) click to toggle source
# File line-em-up/models/launcher.rb, line 76
def update mouse_x = nil, mouse_y = nil, object = nil, scroll_factor = 1
  if @inited && @active
    @x = object.x
    @y = object.y
  end
  @cooldown_wait -= 1.0 if @cooldown_wait > 0.0
  if !@active && @projectiles.count == 0
    return false
  else
    # @projectiles.reject! do |particle|
    #   !particle.parental_update(nil, nil, nil)
    # end

    return true
  end
end