class RubyMan::GhostCorpse
simple object representing dying ghost with respawn functionality
Public Class Methods
new(x, y, phase, direction, res_x, res_y)
click to toggle source
Calls superclass method
# File lib/ruby_man/GameObjects/ghost_corpse.rb, line 6 def initialize(x, y, phase, direction, res_x, res_y) super() @grid_x, @grid_y, = x, y @phase, @direction = phase, direction @res_x, @res_y = res_x, res_y self.sprite = Sprite['ghost_death'] end
Public Instance Methods
respawn()
click to toggle source
# File lib/ruby_man/GameObjects/ghost_corpse.rb, line 23 def respawn ghost = Ghost.new ghost.set_pos(@res_x, @res_y) @game.add_object(ghost) destroy end
update(delta)
click to toggle source
# File lib/ruby_man/GameObjects/ghost_corpse.rb, line 14 def update(delta) next_index = @image_index + @image_speed * delta * @sprite.frames.size if next_index < @sprite.frames.size @image_index = next_index else respawn end end