
Howl to honor the ones fallen in battle...

Group: Expert
Posts: 135
Member No.: 17
Joined: 17-May 06

|
Script created by Dubealex Paralax Background ScriptDownload the playable demo now:Parallax_Background___R2.exeKnown 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 #=================================================== |
Instructions Manual:
Creating the parallax setting list:
New in release 2, you can now set all the default parallax settings for each map that will use a parralax background at the very beggining of the script. This is a sample line:
$map_parallax[ID]=Parallax.new("name", direction, speed,opacity,hue)
You can see 2 settings by default in the script, simply replace them by whatever you want. Replace ID with the map ID, and the other settings by what you want. To add more settings, just copy a line and paste it below the others. To delete settings, simply delete a line. To know how to use the syntax, read on.
To start a Parallax Background:
To start a parallax panoramas, you must insure that your panorama image file is 640X480 and is in the Panoramas directory of your project.
Remember than all parallax set in the script will automatically start upon map load. Which means you don't have to "start" them, nor do anything. Just try the demo, and change the starting position to the other map; you will see that the parallax will start automatically, even if there isn't any auto start or parallel process events on those maps !
But still, you may want to modify a parallax from within the game flow, so you can still do it as in Release 1, just a slight modification at the beggining of the syntax, that's all. So, if you want to re-start, start or modify a parralax, use the following syntax in a call script:
| CODE | $parallax_active=true $map_parallax[ID]= Parallax.new("sky1", 4, 2,255,0) |
(Explanation will follow)
Remember that now, you can modify a parallax setting for another map, even if you aren't in that map yet.
$map_parallax[ID]=Parallax.new("filename", direction, speed, opacity, hue_color)
$map_parallax[ID] Is the name of your map parallax. It is now standard name, and you can't change it. Simply change the ID by the ID # of your map. So to use the parallax from map ID#4, you write "$map_parallax[4]".
Remember the following trick: As you can see in my demo, I oftenly uses the syntax $map_parallax[$game_map.map_id], this is because $game_map.map_id contains the ID of the map you are in. So by using this instead of the raw ID#, I can simply copy and paste event from a map and another, without having to edit anything !
"filename" This is the exact file name of your panorama file, you can omit the file extention. But the name is case sensitve. The file must be in your Graphics\Panoramas folder in your game Project. And the file MUST be 640X480.
direction There you choose a direction in whicj the parallax will move. Here's the choices (Remember ! Those are the numbers on your keyboard's numpad... It's easy to remember !)
0 = Will not move 2 = Down 4 = Left 6 = Right 8 = Up
I still have to work on the 4 other directions, but they are harder to define...
speed Here you choose the speed of the moving panorama. If you set the speed to 0, it won't move either. There are 2 limits of speed:
Vertical Limit (up and down): 60 Horizontal Limit (left and right): 40
Don't worry, if you set the speed higher than that, the script automatically set the speed to the highest possible one.
opacity You choose the opacity of your parallax background here. 0 is transparent (invisible) and 255 is opaque (fully visible). This is useful mainly when used with fade in/out actions. (Explained later).
hue_color You can choose a hue color, just as with the character and fog. 0 will make no changes to the color. Experiment with it to create cool effects.
About Security:
I will tell you this right now, as it is important. As in my Memorize Location Script, I created a "security" variable that is turn to "true" (on) when a parallax is active on the map, and set to "false" (off) when there isn't. That way, you can encapsulate every actions like Erase Parallax, fade in/out and fade loop in a simple conditional branch that will check if that variable is true or not. If it is, you can go on with the actions, if not, you decide what the event will do.
The variable is called "$parallax_active". So to use it in your conditional branches, you simply choose the last page to the right (I think it is page 4) and you go to the last option to the bottom, named "Script". In there, you write this:
| CODE | | $parallax_active==true |
Then, the events you add below it will execute if that is true, meaning if a parallax is active in the map, and you can use the Else Handler to add what happens if there isn't any. Look at my demo for example of this.
How to erase a parallax:
To erase a parallax, you use the following syntax:
| CODE | | $map_parallax[ID].erase |
This will have the effect of erasing the parallax from the map, and it will also set the map default parallax empty. Which means that if you erase it, exit the map and come back, it gonna still be erased. If you just want to make it invisible for a while, just use a fade out.
The fade options:
There are 4 fade actions:
- Fade In - Fade Out - Fade Loop - Stop fade
Here's the syntaxes for each:
FADE IN:
| CODE | | $map_parallax[ID].fade_in(speed) |
FADE OUT:
| CODE | | $map_parallax[ID].fade_out(speed) |
FADE LOOP:
| CODE | | $map_parallax[ID].fade_loop(speed) |
STOP FADE:
| CODE | | $map_parallax[ID].stop_fade |
"Speed" is the speed you want the fading to have, it's pretty simple. I don't have to explain what Fade In and Out do... I hope so. Fade Loop will simply loop the fade In and fade Out actions in queue; it will Fade In , then fade out, then fade in again, etc. Stop fade will stop a fade that is happening.
Conclusion:
So if anybody can help me with the diagonals direction, I'm all ears. I haven't yet try hard to find a solution, I was tired and I wanted to release the script before going to sleep... lol
Beside that, make sure to follow the guidelines the events tells you in my demo, and take care !
If you found any bug, reply to the post and I'll look into it !
--------------------
A true ninja gives his life for the mission...Signature copyright © to me
|