class Mite
Constants
- MAX_ATTACK_SPEED
- POINT_VALUE_BASE
- SPEED
Attributes
armor[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
attack_speed[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
cooldown_wait[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
health[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
x[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
y[RW]
MISSILE_LAUNCHER_MIN_ANGLE = 255 MISSILE_LAUNCHER_MAX_ANGLE = 285 MISSILE_LAUNCHER_INIT_ANGLE = 270
Public Class Methods
new(scale, x, y, screen_width, screen_height, x_direction, options = {})
click to toggle source
Calls superclass method
GeneralObject::new
# File line-em-up/models/mite.rb, line 21 def initialize(scale, x, y, screen_width, screen_height, x_direction, options = {}) # initialize(scale, x, y, screen_width, screen_height, options = {}) super(scale, x, y, screen_width, screen_height, options) @cooldown_wait = 0 @attack_speed = 1 @health = 2 @armor = 0 @current_speed = self.class.get_max_speed * @scale @x_direction = x_direction @switched_directions = false @damage_factor = options[:damage_increase] || 0.3 end
Public Instance Methods
attack(player)
click to toggle source
# File line-em-up/models/mite.rb, line 47 def attack player return { projectiles: [ SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, nil, nil, nil, {damage_increase: @damage_factor}) ], cooldown: SemiGuidedMissile::COOLDOWN_DELAY * MAX_ATTACK_SPEED } end
drops()
click to toggle source
# File line-em-up/models/mite.rb, line 57 def drops value = [SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, nil, {ttl: 2, third_scale: true})] value << Star.new(@scale, @screen_width, @screen_height, @x, @y) if rand(2) == 0 return value end
get_draw_ordering()
click to toggle source
# File line-em-up/models/mite.rb, line 63 def get_draw_ordering ZOrder::Enemy end
get_image()
click to toggle source
# File line-em-up/models/mite.rb, line 17 def get_image Gosu::Image.new("#{MEDIA_DIRECTORY}/mite.png") end
get_points()
click to toggle source
# File line-em-up/models/mite.rb, line 34 def get_points return POINT_VALUE_BASE end
is_alive()
click to toggle source
# File line-em-up/models/mite.rb, line 38 def is_alive @health > 0 end
take_damage(damage)
click to toggle source
# File line-em-up/models/mite.rb, line 43 def take_damage damage @health -= damage end
update(mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1)
click to toggle source
def exec_gl
raise "HERE"
end
# File line-em-up/models/mite.rb, line 71 def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1 @cooldown_wait -= 1 if @cooldown_wait > 0 @time_alive += 1 if is_alive @x = @x + (@current_speed * @x_direction) @y = @y + (Math.sin(@x / 50) * 5 * @scale)# * 20 * @scale if @switched_directions # puts "CASE 1" if @x_direction > 0 # puts "CASE 1.3" @x < @screen_width else # puts 'CASE 1.6' @x > 0 end else if @x_direction < 0 && @x < 0 - @screen_width / 2 # puts "CASE 2: " @switched_directions = true @x_direction = @x_direction * -1 elsif @x_direction > 0 && @x > @screen_width + @screen_width / 2 # puts "CASE 3" @switched_directions = true @x_direction = @x_direction * -1 end # puts "CASE 4" return true end else # puts "CASE 5" false end end