class Environment
def initialize
@animation = nil
@battlers = [Battler.new("some"), Battler.new("ordinary"), Battler.new("objects")]
end
def update
@battlers.each {|battler| battler.update}
end
def draw
@battlers.each {|battler| battler.draw}
if not @animation.nil?
if not @animation.shown
@animation.draw
end
end
end
def performAnimations
@battlers.each do |battler|
# some stuff
@animation = Animation.new(battler.highOugiAnimation)
# wait until animation finished
waitAnimation
end
end
def waitAnimation
if not @animation.nil?
while not @animation.shown
update
draw
end
end
end
end
class Animation
attr_reader :shown
def initialize(animation)
@animation = animation
@shown = false
@pseudoTimer = 0
@pseudoNumber = 1500
end
def draw
@animation.draw(24, 24, 24)
@pseudoTimer += 1
if @pseudoTimer > @pseudoNumber
@shown = true
end
end
end
def update
# ...
if @environment.allAnimationsDone
# prevent animation from showing
elsif @animation.nil?
startAnimation(@environment.getNextAnimation)
elsif !@environment.activeAnimation.nil?
if @animation.shown
if @environment.activeAnimation.state == :DONE
startAnimation(@environment.getNextAnimation)
else
endAnimation(@environment.activeAnimation)
end
end
end
# ...
end
@battlers = [Battler.new("one"), Battler.new("two"), Battler.new("three")]
@battlers.first.animate
@battlers.shift if @battlers.first.animation_done? # remove the first element from the queue
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill