Class: EndPlayer

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/games_paradise/gui/gosu/chinguroids/objects.rb

Overview

END PLAYER

Player clone with no blinking, used in Introduction and Ending gamestates
Adds in some methods to adjust the spaceship size and movement as it descends to Earth

Instance Method Summary collapse

Instance Method Details

#accelerateObject



467
468
469
470
471
472
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 467

def accelerate
  if self.velocity_x <= @max_speed && self.velocity_y <= @max_speed
    self.velocity_x += Gosu::offset_x(self.angle, @speed)
    self.velocity_y += Gosu::offset_y(self.angle, @speed)
  end
end

#adjust_particlesObject



478
479
480
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 478

def adjust_particles
  @particles_slow = 0.997
end

#decelerateObject



474
475
476
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 474

def decelerate
  @easing = 0.99
end

#setupObject



447
448
449
450
451
452
453
454
455
456
457
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 447

def setup
  @image = Gosu::Image["assets/player.png"]
  @width, @height = 32, 32
  @speed = 0.34
  @max_speed, @part_speed, @rotate_speed = 10, 8, 5
  @shoot = Sound["media/audio/laser.OGG"]
  @easing = 1.0          # amount to slow down EndPlayer each tick
  @shrinkage = 1.0       # amount to scale image each tick
  @particles_slow = 1.0  # amount to adjust particle particle speed
  self.factor = 1.0
end

#shrink1Object

method called in Ending gamestate



459
460
461
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 459

def shrink1   # method called in Ending gamestate
  @shrinkage = 0.998
end

#shrink2Object

method called in Ending gamestate



463
464
465
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 463

def shrink2   # method called in Ending gamestate
  @shrinkage = 0.996
end

#updateObject



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/games_paradise/gui/gosu/chinguroids/objects.rb', line 482

def update
  self.factor *= @shrinkage
  @part_speed *= @particles_slow
  self.velocity_x *= @easing
  self.velocity_y *= @easing

   Chingu::Particle.create(:x => @x, :y => @y,
          :image => "assets/particle_1.png", 
          :color => 0xFF86EFFF, 
          :mode => :default,
          :fade_rate => -45,
          :angle => @angle,
          :factor => @factor,
          :zorder => Zorder::Main_Character_Particles)

   Chingu::Particle.each { |particle| particle.y -= Gosu::offset_y(@angle, @part_speed); particle.x -= Gosu::offset_x(@angle, @part_speed)}
   Chingu::Particle.destroy_if { |object| object.outside_window? || object.color.alpha == 0 }
end