class LaserParticle
For opengl-bindings OpenGL.load_lib() GLUT.load_lib()
Constants
- DAMAGE
- MAX_SPEED
DAMAGE
= 0.1 COOLDOWN_DELAY = 1 Friendly projects are + speeds
Attributes
active[RW]
background_image_height_half[RW]
background_image_width_half[RW]
collision[RW]
image_background[RW]
position[RW]
Public Class Methods
new(scale, screen_width, screen_height, object, options = {})
click to toggle source
Calls superclass method
DumbProjectile::new
# File line-em-up/models/laser_particle.rb, line 25 def initialize(scale, screen_width, screen_height, object, options = {}) options[:debug] = true options[:relative_y_padding] = -(object.image_height_half) super(scale, screen_width, screen_height, object, options) @active = true if options[:is_head] @position = :is_head @image_background = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-end-background.png") @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-end-overlay.png") elsif options[:is_tail] @position = :is_tail @image_background = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-background.png") @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png") else @image_background = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-background.png") @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-overlay-half.png") end @background_image_width_half = get_background_image.width / 2 @background_image_height_half = get_background_image.height / 2 @collision = false end
Public Instance Methods
collision_triggers()
click to toggle source
# File line-em-up/models/laser_particle.rb, line 90 def collision_triggers @collision = true end
draw()
click to toggle source
include Gl include Glu include Glut
# File line-em-up/models/laser_particle.rb, line 99 def draw if @inited# && !@active # @image_background.draw(@x - @background_image_width_half, @y - @background_image_height_half, get_draw_ordering, @scale, @scale) @image.draw(@x - @image_width_half, @y - @image_height_half, get_draw_ordering, @scale, @scale) end end
draw_gl()
click to toggle source
# File line-em-up/models/laser_particle.rb, line 106 def draw_gl # if @inited# && !@active # new_width1, new_height1, increment_x, increment_y = LaserParticle.convert_x_and_y_to_opengl_coords(@x - @image_width_half/8, @y - @image_height_half/2, @screen_width, @screen_height) # new_width2, new_height2, increment_x, increment_y = LaserParticle.convert_x_and_y_to_opengl_coords(@x - @image_width_half/8, @y + @image_height_half/2, @screen_width, @screen_height) # new_width3, new_height3, increment_x, increment_y = LaserParticle.convert_x_and_y_to_opengl_coords(@x + @image_width_half/8, @y - @image_height_half/2, @screen_width, @screen_height) # new_width4, new_height4, increment_x, increment_y = LaserParticle.convert_x_and_y_to_opengl_coords(@x + @image_width_half/8, @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) # # glVertex3f(new_width4, new_height4, 0.0) # glEnd # 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) # glVertex3f(new_width4, new_height4, 0.0) # glEnd # end end
get_background_image()
click to toggle source
# File line-em-up/models/laser_particle.rb, line 53 def get_background_image # Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-overlay.png") if @position == :is_head return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-end-background.png") elsif @position == :is_tail return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-background.png") else return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-background.png") end end
get_draw_ordering()
click to toggle source
# File line-em-up/models/laser_particle.rb, line 49 def get_draw_ordering ZOrder::LaserParticle end
get_image()
click to toggle source
# File line-em-up/models/laser_particle.rb, line 64 def get_image # Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-overlay.png") if @position == :is_head return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png") elsif @position == :is_tail return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-end-overlay.png") else return Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-middle-overlay.png") end end
parental_update(mouse_x = nil, mouse_y = nil, player = nil)
click to toggle source
# File line-em-up/models/laser_particle.rb, line 82 def parental_update mouse_x = nil, mouse_y = nil, player = nil if @inited @y -= @current_speed @x = player.x if player && @active @y > 0 && @y < @screen_height end end
update(mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1)
click to toggle source
# File line-em-up/models/laser_particle.rb, line 75 def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1 if @inited @time_alive += 1 @y > 0 && @y < @screen_height end end