class Mothership
Constants
- MAX_ATTACK_SPEED
- MISSILE_LAUNCHER_INIT_ANGLE
- MISSILE_LAUNCHER_MAX_ANGLE
- MISSILE_LAUNCHER_MIN_ANGLE
- POINT_VALUE_BASE
- SPEED
Attributes
armor[RW]
attack_speed[RW]
cooldown_wait[RW]
health[RW]
secondary_cooldown_wait[RW]
tertiary_cooldown_wait[RW]
x[RW]
y[RW]
Public Class Methods
new(scale, screen_width, screen_height, options = {})
click to toggle source
Calls superclass method
GeneralObject::new
# File line-em-up/models/mothership.rb, line 23 def initialize(scale, screen_width, screen_height, options = {}) super(scale, screen_width / 2, get_image.height, screen_width, screen_height, options) @cooldown_wait = 0 @secondary_cooldown_wait = 0 @tertiary_cooldown_wait = 0 @attack_speed = 0.5 @health = 2500 @armor = 0 @current_speed = (SPEED * @scale).round + 1 end
Public Instance Methods
attack(player)
click to toggle source
# File line-em-up/models/mothership.rb, line 55 def attack player return { projectiles: [ EnemyBullet.new(@scale, @screen_width, @screen_height, self, {side: 'left', relative_object: self }), EnemyBullet.new(@scale, @screen_width, @screen_height, self, {side: 'right', relative_object: self }), EnemyBullet.new(@scale, @screen_width, @screen_height, self) ], cooldown: EnemyBullet::COOLDOWN_DELAY } end
drops()
click to toggle source
# File line-em-up/models/mothership.rb, line 86 def drops [ SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, @image) # Star.new(@scale, @x, @y) ] end
get_draw_ordering()
click to toggle source
# File line-em-up/models/mothership.rb, line 93 def get_draw_ordering ZOrder::Enemy end
get_image()
click to toggle source
# File line-em-up/models/mothership.rb, line 19 def get_image Gosu::Image.new("#{MEDIA_DIRECTORY}/mothership.png") end
get_points()
click to toggle source
def draw
# Will generate error if class name is not listed on ZOrder @image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering, @scale, @scale) # @image.draw(@xΩ - @image.width / 2, @y - @image.height / 2, get_draw_ordering)
end
# File line-em-up/models/mothership.rb, line 41 def get_points return POINT_VALUE_BASE end
is_alive()
click to toggle source
# File line-em-up/models/mothership.rb, line 45 def is_alive @health > 0 end
secondary_attack(player)
click to toggle source
# File line-em-up/models/mothership.rb, line 66 def secondary_attack player return { projectiles: [ # relative_object not required yet for these SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', relative_object: self }), SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', relative_object: self }) ], cooldown: SemiGuidedMissile::COOLDOWN_DELAY } end
take_damage(damage)
click to toggle source
# File line-em-up/models/mothership.rb, line 50 def take_damage damage @health -= damage end
tertiary_attack(player)
click to toggle source
# File line-em-up/models/mothership.rb, line 78 def tertiary_attack player return { projectiles: [EnemyBomb.new(@scale, @screen_width, @screen_height, self, player.x, player.y)], cooldown: EnemyBomb::COOLDOWN_DELAY } end
update(mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1)
click to toggle source
end
# File line-em-up/models/mothership.rb, line 102 def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1 @cooldown_wait -= 1 if @cooldown_wait > 0 @secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0 @tertiary_cooldown_wait -= 1 if @tertiary_cooldown_wait > 0 if is_alive # Stay above the player if player.is_alive && player.y < @y @y -= @current_speed else if rand(2).even? @y += @current_speed @y = @screen_height / 2 if @y > @screen_height / 2 else @y -= @current_speed @y = 0 + (get_height / 2) if @y < 0 + (get_height / 2) end end if rand(2).even? @x += @current_speed @x = @screen_width if @x > @screen_width else @x -= @current_speed @x = 0 + (get_width / 2) if @x < 0 + (get_width / 2) end @y < @screen_height + (get_height / 2) else false end end