Академический Документы
Профессиональный Документы
Культура Документы
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as change in color tone,
# flashing, etc. Refer to "$game_screen" for the instance of this class.
#==============================================================================
class Game_Screen
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :shake_y # shake positioning - Y
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias shake_ex_initialize initialize
def initialize
# Perform the original call
shake_ex_initialize
# Set the default values
@shake_y, @shake_y_power, @shake_y_direction = 0, 0, 1
end
#--------------------------------------------------------------------------
# * Start Shaking
# power : strength
# speed : speed
# duration : time
#--------------------------------------------------------------------------
alias shake_ex_start_shake start_shake
def start_shake(power, speed, duration)
# Perform the original call
shake_ex_start_shake(power, speed, duration)
# Set Vertical Shake power to 75% of horizontal power (20x15 tiled map value
)
@shake_y_power = power * 3 / 4 if $game_variables[SHAKE_VARIABLE] > 0
# Remove Horizontal Shake Power if no horizontal action permitted
@shake_power = 0 if $game_variables[SHAKE_VARIABLE] == 1
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias shake_ex_update update
def update
# Perform the original call
shake_ex_update
# Perform vertical shaking if set
if $game_variables[SHAKE_VARIABLE] > 0
# Modeled after the original call
if @shake_duration >= 1 or @shake_y != 0
delta = (@shake_y_power * @shake_speed * @shake_y_direction) / 10.0
if @shake_duration <= 1 && @shake_y * (@shake_y + delta) < 0
@shake_y = 0
else
@shake_y += delta
end
@shake_y_direction = -1 if @shake_y > @shake_y_power * 1.5
@shake_y_direction = 1 if @shake_y < -@shake_y_power * 1.5
end
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias shake_ex_update update
def update
# Set screen y shake position dependent on Shake Variable Setting
@viewport1.oy = ($game_variables[SHAKE_VARIABLE] > 0 ? $game_screen.shake_y
: 0)
# Perform the original call
shake_ex_update
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within
# the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias shake_ex_update update
def update
# Set screen y shake position dependent on Shake Variable Setting
@viewport1.oy = ($game_variables[SHAKE_VARIABLE] > 0 ? $game_screen.shake_y
: 0)
# Perform the original call
shake_ex_update
end
end