Code:
#==============================================================================
# *** AWorks Frame Skip(AFS)
#------------------------------------------------------------------------------
# Creted by AWorks(vgvgf)
# Version: 1.10
# Updated: 11/08/2009 (dd/mm/yyyy)
#------------------------------------------------------------------------------
#==== Description ====
# This script lets the game to skip frames, and as these frames are not drawed
# the game will advance faster.
# Compatible with RMXP and RMVX.
#------------------------------------------------------------------------------
#==== Instructions ====
# There are two frame skip modes, one which skip frames each time the screen
# is updated, and the other which will skip an amount of frames per second.
# The first one will let the game to play faster, but the second one is
# smoother.
#
# * Graphics.frame_skip_mode = mode
# Changes the frame skip mode. Set it to 0 or 1.
#
# * Graphics.frame_skip_rate = rate
# Changes the frame skip rate, the higher the number the faster it goes.
# If it is 0, frame skip will be deactivated.
#
# * FRAME_SKIP_PLAY_TEST
# If true, frame skip will be activated when a key is press on Play Test
# mode. ALT by default.
#
# * FRAME_SKIP_PLAY_TEST_MODE
# Change the frame skip mode for Play Test.
#
# * FRAME_SKIP_PLAY_TEST_RATE
# Change the frame skip rate for Play Test.
#
# * FRAME_SKIP_PLAY_TEST_BUTTON
# Change the frame skip key for Play Test.
#==============================================================================
#==============================================================================
# ** Graphics Module
#==============================================================================
module Graphics
#----------------------------------------------------------------------------
# * Opciones
#----------------------------------------------------------------------------
FRAME_SKIP_PLAY_TEST = true
FRAME_SKIP_PLAY_TEST_MODE = 0
FRAME_SKIP_PLAY_TEST_RATE = 5
FRAME_SKIP_PLAY_TEST_BUTTON = Input::ALT
#----------------------------------------------------------------------------
# * Variables
#----------------------------------------------------------------------------
@frame_skip_rate = 0
@frame_skip_count = 0
@frame_skip_mode = 0
#----------------------------------------------------------------------------
FRAME_SKIP_PLAY_TEST = false if (!$DEBUG and !$TEST and !$BTEST) or
FRAME_SKIP_PLAY_TEST_RATE <= 0
class << self
attr_accessor(:frame_skip_rate, :frame_skip_mode)
if @aworks_frameskip_alias.nil?
alias_method(:aworks_graphics_update, :update)
alias_method(:aworks_graphics_transition, :transition)
@aworks_frameskip_alias = true
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update(*args)
if @frame_skip_rate > 0
if @frame_skip_mode == 0
@frame_skip_count += 1
if @frame_skip_count >= @frame_skip_rate
@frame_skip_count = 0
else
return
end
else
@frame_skip_count += [@frame_skip_rate, frame_rate / 2].min
if @frame_skip_count >= frame_rate
@frame_skip_count = 0
return
end
end
elsif FRAME_SKIP_PLAY_TEST and Input.press?(FRAME_SKIP_PLAY_TEST_BUTTON)
if FRAME_SKIP_PLAY_TEST_MODE == 0
@frame_skip_count += 1
if @frame_skip_count >= FRAME_SKIP_PLAY_TEST_RATE
@frame_skip_count = 0
else
return
end
else
@frame_skip_count += [@frame_skip_rate,
FRAME_SKIP_PLAY_TEST_RATE / 2].min
if @frame_skip_count >= FRAME_SKIP_PLAY_TEST_RATE
@frame_skip_count = 0
return
end
end
end
aworks_graphics_update(*args)
end
end
end