#encoding:utf-8
##
# Ugoku
# author: Calendar99
#
# use arrow keys to make your message window ugokemasu.
##
class Window_Message
dur = 15
power = 90
tw = ->(ab, inout) { "Tween.new(#{ab}, Tween::Cubic::#{inout}, #{dur})" }
expo_tws = "->(a, b) { [(#{tw['a, b','Out']}), (#{tw['b, a' ,'In']})] }"
{
:down => [:oy, "->(ox, oy) { (#{expo_tws})[oy, oy - #{power}] }"],
:up => [:oy, "->(ox, oy) { (#{expo_tws})[oy, oy + #{power}] }"],
:right => [:ox, "->(ox, oy) { (#{expo_tws})[ox, ox - #{power}] }"],
:left => [:ox, "->(ox, oy) { (#{expo_tws})[ox, ox + #{power}] }"],
}.each {|meth, (attr, tws)|
class_eval %{
def ugoku_#{meth}
if @#{attr}_tweens.empty?
@#{attr}_tweens += (#{tws}).call(ox, oy)
else
@#{attr}_tweens.shift until @#{attr}_tweens.size == 1
@#{attr}_tweens.unshift (#{tws}).call(ox, oy)[0]
@#{attr}_tweens[1].start[0] = @#{attr}_tweens[0].finish[0]
@#{attr}_tweens[1].rewind
end
end
}
}
alias initialize_ugoku_calendar99 initialize
def initialize
initialize_ugoku_calendar99
@ox_tweens = []
@oy_tweens = []
end
alias update_ugoku_calendar99 update
def update
process_ugoku
update_ugoku
update_ugoku_calendar99
end
def process_ugoku
return unless active && open?
ugoku_down if Input.trigger?(:DOWN)
ugoku_up if Input.trigger?(:UP)
ugoku_right if Input.trigger?(:RIGHT)
ugoku_left if Input.trigger?(:LEFT)
end
upd = ->(param) {
%{
unless @#{param}_tweens.empty?
if @#{param}_tweens[0].done
@#{param}_tweens.shift
end
if tw = @#{param}_tweens[0]
tw.update
self.#{param} = tw.value
end
end
}
}
class_eval %{
def update_ugoku
#{upd['ox']}
#{upd['oy']}
end
}
end