Parallax Horizon
Version: 1.0
Author: modern algebra
Date: August 2, 2008
Version History
- <Version 1.0> August 2 2008 - Original Release
Description
This script allows you to set a speed for a parallax to scroll extra when the player is moving. It will scroll in the opposite direction, to give the illusion of a horizon to which the player is moving.
Features
- Allows you to set the parallax to have an illusory horizon
- Allows you to set the speed map by map
- Scrolls only in the opposite direction of the way you are moving, while you are moving.
- Is completely compatible with the default scrolling, so that you can even combine the two.
- Supports dashing, so the speed you set is doubled when the player is dashing, so the parallax is moving at the correct speed always.
Screenshots
Not applicable
Instructions
See inside the script for instructions
Script
#==============================================================================
# Parallax Horizon
# Version 1.0
# Author: modern algebra (rmrk.net)
# Date: August 2, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Description:
# This script allows you to set a speed for a parallax to scroll extra
# when the player is moving. It will scroll in the opposite direction, to
# give the illusion of a horizon.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# To make it so that the parallax will scroll, you must check the box in the
# map settings for it to scroll, even if you do not want it to scroll
# regularly. You can avoid it scrolling regularly by leaving the scroll value
# at 0. For instructions on setting up the maps, see the CONFIGURABLE REGION
# at line 49. You can also use this code:
#
# $game_map.p_scroll_mod =
#
# to set the speed manually in game. It will reset once you leave the map.
#==============================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new public instance variable - p_scroll_mod
# aliased method - update_parallax
#==============================================================================
class Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :p_scroll_mod
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Parallax
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_arclg_req_parallax_moving_response_53b6 update_parallax
def update_parallax
# IF player is moving and parallax stats not updated yet
if $game_player.moving? && @old_parallax_sx == nil
# Set variables to save the default values of parallax stats
@old_parallax_sx = @parallax_sx
@old_parallax_sy = @parallax_sy
# Initialize scroll modifier
if @p_scroll_mod == nil
@p_scroll_mod = case map_id
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# CONFIGURABLE REGION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# To configure this script, set up the lines below like this:
#
# when map_id then scroll_speed
#
# So if you set:
# when 1 then 10
#
# That means that the parallax on Map with ID 1 will scroll at
# speed 10 in the opposite direction when the player is moving.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
when 1 then 10
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END CONFIGURABLE REGION
#//////////////////////////////////////////////////////////////////
else
0
end
end
# Modify the scrolling
if @p_scroll_mod != 0
# Adjust for dashing
mod = $game_player.dash? ? @p_scroll_mod*2 : @p_scroll_mod
# Adjust scroll in the direction the player is moving
@parallax_sx -= mod if $game_player.x * 256 < $game_player.real_x
@parallax_sx += mod if $game_player.x * 256 > $game_player.real_x
@parallax_sy -= mod if $game_player.y * 256 < $game_player.real_y
@parallax_sy += mod if $game_player.y * 256 > $game_player.real_y
end
# Restore Parallax Scroll to default if not moving
elsif @old_parallax_sx != nil
@parallax_sx = @old_parallax_sx
@parallax_sy = @old_parallax_sy
@old_parallax_sx = nil
@old_parallax_sy = nil
end
# Run Original Method
modalg_arclg_req_parallax_moving_response_53b6
end
end
Credit
Thanks
- arclight, for requesting this useful script
Support
Please post here at rmrk.net for the swiftest response
Demo
Not really necessary.
This script by
modern algebra is licensed under a
Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.