Вы находитесь на странице: 1из 3

#==============================================================================

# ** Screen Shake Extended


#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.0
# 12-30-2009
# RGSS / RPGMaker XP
#==============================================================================
#
# INTRODUCTION:
#
# Dude, I remember that good-old RPGMaker 2000 allowed you to shake the screen
# vertically as well as horizontally. WHY DID THEY REMOVE IT!? Dunno, but it
# is back.
#
#------------------------------------------------------------------------------
#
# INSTRUCTIONS:
#
# Set the "SHAKE VARIABLE" to the ID of your RPGMaker XP variable you wish to
# use to control your shaking system. This way, you can use the default map
# 'Control Variables' system to change the shaking system to however you want.
#
# Values you can assign your RPGMaker XP variable to control shaking are as
# follows:
#
# 0 = The default horizontal only shake
# 1 = The new 'vertical only' shake
# 2 = The new 'horiz/verti' shake
#
# You set the power, speed and duration of the screen shake through the use
# of the SCREEN SHAKE map event as normal.
#
#------------------------------------------------------------------------------
# TERMS AND CONDITIONS:
#
# Free for use, even in commercial games. However, this is an exclusive to
# the 'House Slashers' run by DerVVulfman, Kalier and Mea, and an exclusive
# to the 'RMVXPUniverse' forum owned by PK8 (formerly Punk, Punkid89), and
# run with Olivia and DerVVulfman. It is not for display or distribution
# on any other site or forum.
#
#==============================================================================

# The RGSS/RMXP Variable


SHAKE_VARIABLE = 2

#==============================================================================
# ** 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

Вам также может понравиться