Class: GamesAndRpgParadise::EndPlayer

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/games_and_rpg_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



470
471
472
473
474
475
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 470

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



481
482
483
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 481

def adjust_particles
  @particles_slow = 0.997
end

#decelerateObject



477
478
479
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 477

def decelerate
  @easing = 0.99
end

#setupObject



450
451
452
453
454
455
456
457
458
459
460
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 450

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



462
463
464
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 462

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

#shrink2Object

method called in Ending gamestate



466
467
468
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 466

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

#updateObject



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/objects.rb', line 485

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