11-26-2004, 01:00 PM
Parallax Background Script
by Dubealex
Nov 26 2004
Download the playable demo now:
Parallax_Background___R2.exe (Size: 1.17 MB / Downloads: 2)
This is the real R2 demo... I forgot to update this.
New Release #2 now available !
Known issues:
- Crashes on first message (in the demo):
You can download a working RGSS100J.DLL file from our download section and paste it over your one in windows\system32 -- You may have a corrupted DLL. This one has been proven to work with many script.
Infos:
This script will allow you to use the good old Parallax Background of RM2K and RM2K3 in RMXP. At the moment, only 4 directions are possible; up, down, left and right. But it's complicated to do the diagonals one (up-left, up-right, down-left and down-right).
I also used my first "Alias" method... neat stuff those alias. I'll be able to enhance all my past script with that, now that I know how it works...
Features:
- Move a panorama at the desired speed, in the desired direction.
- Fade in/out a panorama, even if moving.
- Fade Loop feature - Can make a panorama "blink".
- Stop Fade >> Can stop any fading anytime.
- Erase panoramas when you want to.
- Save parallax when you save a game (New in R2)
- Automatic parallax start upon map load ! (New in R2)
The script you need:
To use that script, simply add a page in your script editor (press INSERT) just above MAIN, and paste all that code in it.
(The instructions manual will follow, as usual.)
by Dubealex
Nov 26 2004
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Download the playable demo now:
Parallax_Background___R2.exe (Size: 1.17 MB / Downloads: 2)
This is the real R2 demo... I forgot to update this.
New Release #2 now available !
Known issues:
- Crashes on first message (in the demo):
You can download a working RGSS100J.DLL file from our download section and paste it over your one in windows\system32 -- You may have a corrupted DLL. This one has been proven to work with many script.
Infos:
This script will allow you to use the good old Parallax Background of RM2K and RM2K3 in RMXP. At the moment, only 4 directions are possible; up, down, left and right. But it's complicated to do the diagonals one (up-left, up-right, down-left and down-right).
I also used my first "Alias" method... neat stuff those alias. I'll be able to enhance all my past script with that, now that I know how it works...
Features:
- Move a panorama at the desired speed, in the desired direction.
- Fade in/out a panorama, even if moving.
- Fade Loop feature - Can make a panorama "blink".
- Stop Fade >> Can stop any fading anytime.
- Erase panoramas when you want to.
- Save parallax when you save a game (New in R2)
- Automatic parallax start upon map load ! (New in R2)
The script you need:
To use that script, simply add a page in your script editor (press INSERT) just above MAIN, and paste all that code in it.
(The instructions manual will follow, as usual.)
Code:
#===================================================
# ■ Parallax Background - R2- Created by dubealex
# - Moving Panoramas & More -
#===================================================
# For more infos and update, visit:
# asylum.dubealex.com
#
# December 8, 2004
#===================================================
#===================================================
# ▼ CLASS Create_Parallax_List Begins
#===================================================
class Create_Parallax_List
def initialize
=begin -----------------------------------------------------------------------------------------------------
■ Map Parallax Background Settings:
---------------------------------------------------------------------------------------------------------
▼ DEFAULT PARALLAX SETTING FOR EACH MAP:
The following list of lines defines each default parallax settings for each map using a
parallax background. The number between square brackets is the map ID. Example:
$map_parallax[3] will refer to the parallax settings of your map ID #3. Just copy the line
to add more settings to all the maps using parallax. The rest will be done automatically by
the script when you load a map in the game. This way you don't have to set full of code in
your teleport, and you can save/load a game and it will work perfectly, as the script now
save the parallax settings in the save file. The parallax settings and syntax is the same as in
previous release: Parallax.new("name", direction, speed, opacity, hue)
Read the manual and play the demo for more info and details about how to manipulate
your parallax within the game. (It's the same way as before, but now you use the right
map ID, so you would do $map_parallax[1].fade_out(2) to fade the parallax of map ID#2.)
=end #----------------------------------------------------------------------------------------------------
$map_parallax[1]=Parallax.new("sky2", 6, 2,255,0)
$map_parallax[2]=Parallax.new("hell1",4,2,255, 0)
#--- ■ END OF SETTINGS-----------------------------------------------------------------------------
end
end
#===================================================
# ▲ CLASS Create_Parallax_List Ends
#===================================================
#===================================================
# ▼ CLASS Parallax Begins
#===================================================
class Parallax
attr_accessor :name, :direction, :speed, :opacity, :hue, :fade
def initialize(name, direction, speed, opacity, hue)
@name=name
@direction=direction
@speed=speed
@opacity=opacity
@hue=hue
@speed=speed
@fade=fade
if $parallax_active==true
$parallax_move[3]=name
$parallax_move[4]=hue
$parallax = Sprite.new
$parallax.bitmap = RPG::Cache.panorama(name, hue)
$parallax.x = 0
$parallax.y = 0
$parallax.z = -500
$parallax.opacity = opacity
if direction != 0 and speed != 0
case direction
when 2, 8
if speed > 60
speed=60
end
when 4, 6
if speed > 40
speed=40
end
end
move(direction, speed)
end
end
end
#------------------------------------------------------------------------------------------------------
def erase
$parallax_active=false
$map_parallax[$game_map.map_id]=nil
$parallax_fade[0]=0
$parallax_move[0]=0
if $parallax.nil? == false :$parallax.dispose end
if $parallax_dummy_l.nil? == false :$parallax_dummy_l.dispose end
if $parallax_dummy_r.nil? == false :$parallax_dummy_r.dispose end
if $parallax_dummy_d.nil? == false :$parallax_dummy_d.dispose end
if $parallax_dummy_u.nil? == false :$parallax_dummy_u.dispose end
end
#------------------------------------------------------------------------------------------------------
def fade_in(speed)
if @speed == 0
$parallax_direction=0
end
$parallax_fade[0]=1
$parallax_fade[1]=speed
end
#------------------------------------------------------------------------------------------------------
def fade_out(speed)
if @speed == 0
$parallax_direction=0
end
$parallax_fade[0]=2
$parallax_fade[1]=speed
end
#------------------------------------------------------------------------------------------------------
def stop_fade
$parallax_fade[0]=0
end
#------------------------------------------------------------------------------------------------------
def fade_loop(speed)
if @speed == 0
$parallax_direction=0
end
$parallax_fade[0]=3
$parallax_fade[1]=speed
$parallax_fade[2]=1
end
#------------------------------------------------------------------------------------------------------
def move(direction, speed)
$parallax_direction=direction
$parallax_move[0]=1
$parallax_move[1]=speed
$parallax_move[2]=0
end
end
#===================================================
# ▲ CLASS Parallax Ends
#===================================================
#===================================================
# ▼ CLASS Scene_Map Additional Code Begins
#===================================================
class Scene_Map
alias parallax_original_update update
def update
parallax_original_update
case $parallax_fade[0]
when 1 #Fade In
case $parallax_direction
when 0 #Not Moving
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 2 #Moving down
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_u.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 6 #Moving right
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_l.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 4 #Moving left
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_r.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 8 #Moving up
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_d.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[0]=0
end
end
when 2 #Fade Out
case $parallax_direction
when 0 #Not Moving
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 2 #Moving down
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_u.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 4 #Moving left
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_r.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 6 #Moving right
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_l.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[0]=0
end
when 8 #Moving up
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_d.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[0]=0
end
end
when 3 #Fade Loop
case $parallax_direction
when 0 #Not Moving
case $parallax_fade[2] when 1 then
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[2]=2
end
when 2
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[2]=1
end
end
when 2 #Moving down
case $parallax_fade[2] when 1 then
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_u.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[2]=2
end
when 2
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_u.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[2]=1
end
end
when 8 #Moving up
case $parallax_fade[2] when 1 then
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_d.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[2]=2
end
when 2
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_d.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[2]=1
end
end
when 6 #Moving right
case $parallax_fade[2] when 1 then
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_l.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[2]=2
end
when 2
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_l.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[2]=1
end
end
when 4 #Moving left
case $parallax_fade[2] when 1 then
unless $parallax.opacity == 255
$parallax.opacity+=$parallax_fade[1]
$parallax_dummy_r.opacity+=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity+=$parallax_fade[1]
else
$parallax_fade[2]=2
end
when 2
unless $parallax.opacity == 0
$parallax.opacity-=$parallax_fade[1]
$parallax_dummy_r.opacity-=$parallax_fade[1]
$map_parallax[$game_map.map_id].opacity-=$parallax_fade[1]
else
$parallax_fade[2]=1
end
end
end
end
case $parallax_move[0]
when 1
if $parallax_move[2]==0
case $parallax_direction
when 4
$parallax_dummy_r = Sprite.new
$parallax_dummy_r.bitmap = RPG::Cache.panorama($parallax_move[3], $parallax_move[4])
$parallax_dummy_r.x = 640
$parallax_dummy_r.y = 0
$parallax_dummy_r.z = -500
$parallax_dummy_r.opacity = $parallax.opacity
when 6
$parallax_dummy_l = Sprite.new
$parallax_dummy_l.bitmap = RPG::Cache.panorama($parallax_move[3], $parallax_move[4])
$parallax_dummy_l.x = -640
$parallax_dummy_l.y = 0
$parallax_dummy_l.z = -500
$parallax_dummy_l.opacity = $parallax.opacity
when 8
$parallax_dummy_d = Sprite.new
$parallax_dummy_d.bitmap = RPG::Cache.panorama($parallax_move[3], $parallax_move[4])
$parallax_dummy_d.x = 0
$parallax_dummy_d.y = 480
$parallax_dummy_d.z = -500
$parallax_dummy_d.opacity = $parallax.opacity
when 2
$parallax_dummy_u = Sprite.new
$parallax_dummy_u.bitmap = RPG::Cache.panorama($parallax_move[3], $parallax_move[4])
$parallax_dummy_u.x = 0
$parallax_dummy_u.y = -480
$parallax_dummy_u.z = -500
$parallax_dummy_u.opacity = $parallax.opacity
end
$parallax_move[2]=1
end
case $parallax_direction
when 4
$parallax_dummy_r.x-=$parallax_move[1]
$parallax.x-=$parallax_move[1]
if $parallax_dummy_r.x==0
$parallax.x=640
end
if $parallax.x==0
$parallax_dummy_r.x=640
end
when 6
$parallax_dummy_l.x+=$parallax_move[1]
$parallax.x+=$parallax_move[1]
if $parallax.x==640
$parallax.x=-640
end
if $parallax_dummy_l.x==640
$parallax_dummy_l.x=-640
end
when 8
$parallax_dummy_d.y-=$parallax_move[1]
$parallax.y-=$parallax_move[1]
if $parallax_dummy_d.y==0
$parallax.y=480
end
if $parallax.y==0
$parallax_dummy_d.y=480
end
when 2
$parallax_dummy_u.y+=$parallax_move[1]
$parallax.y+=$parallax_move[1]
if $parallax_dummy_u.y==0
$parallax.y=-480
end
if $parallax.y==0
$parallax_dummy_u.y=-480
end
end
end
end
end
#===================================================
# ▲ CLASS Scene_Map Additional Code Ends
#===================================================
#===================================================
# ▼ CLASS Scene_Save Additional Code Begins
#===================================================
class Scene_Save < Scene_File
alias parallax_original_write_save_data write_save_data
def write_save_data(file)
parallax_original_write_save_data(file)
Marshal.dump($map_parallax, file)
end
end
#===================================================
# ▲ CLASS Scene_Save Additional Code Ends
#===================================================
#===================================================
# ▼ CLASS Scene_Load Additional Code Begins
#===================================================
class Scene_Load < Scene_File
alias parallax_original_read_save_data read_save_data
def read_save_data(file)
parallax_original_read_save_data(file)
$map_parallax = Marshal.load(file)
end
end
#===================================================
# ▲ CLASS Scene_Load Additional Code Ends
#===================================================
#===================================================
# ▼ CLASS Scene_Title Additional Code Begins
#===================================================
class Scene_Title
$map_parallax=[]
$parallax_fade=[]
$parallax_move=[]
$parallax_direction=0
$parallax_active=false
Create_Parallax_List.new
end
#===================================================
# ▲ CLASS Scene_Title Additional Code Ends
#===================================================
#===================================================
# ▼ CLASS Spriteset_Map Additional Code Begins
#===================================================
class Spriteset_Map
alias parallax_original_initialize initialize
def initialize
parallax_original_initialize
$parallax_active=false
$parallax_fade[0]=0
$parallax_move[0]=0
if $parallax.nil? == false :$parallax.dispose end
if $parallax_dummy_l.nil? == false :$parallax_dummy_l.dispose end
if $parallax_dummy_r.nil? == false :$parallax_dummy_r.dispose end
if $parallax_dummy_d.nil? == false :$parallax_dummy_d.dispose end
if $parallax_dummy_u.nil? == false :$parallax_dummy_u.dispose end
if $map_parallax[$game_map.map_id] != nil
name=$map_parallax[$game_map.map_id].name
direction=$map_parallax[$game_map.map_id].direction
speed=$map_parallax[$game_map.map_id].speed
opacity=$map_parallax[$game_map.map_id].opacity
hue=$map_parallax[$game_map.map_id].hue
$parallax_active=true
Parallax.new(name, direction, speed,opacity,hue)
end
end
end
#===================================================
# ▲ CLASS Spriteset_Map Additional Code Ends
#===================================================
Instruction Manual: