- Joined
- Mar 18, 2012
- Messages
- 3,905
- Reaction score
- 451
- First Language
- April Fools
- Primarily Uses
- N/A
I really like the way Original Wij did his multiple-parallaxed-layers-v1-0 script for RPG Maker VX and sadly I got used to using it in a lot of my VX projects.
I would really like it added to my unlimited parallax layers for RGSS3 aka RPG Maker VX Ace!!
I mainly like the fact I can use maps as battle Backgrounds and parallaxes together.
here is the link to Original Wijs page for it
http://originalwij.wordpress.com/2010/05/31/multiple-parallaxed-layers-v1-0/
and here is the script itself
I would really like it added to my unlimited parallax layers for RGSS3 aka RPG Maker VX Ace!!
I mainly like the fact I can use maps as battle Backgrounds and parallaxes together.
here is the link to Original Wijs page for it
http://originalwij.wordpress.com/2010/05/31/multiple-parallaxed-layers-v1-0/
and here is the script itself
Code:
#==============================================================================# Multiple Parallaxed Layers#==============================================================================# Author : OriginalWij# Version : 1.0#==============================================================================#==============================================================================# Version History# ---------------## NOTE: The newest version is the ONLY supported version!## v1.0# - Initial release# - Parallax Maps script no longer supported due to inclusion in this script#==============================================================================#==============================================================================# To use: place one or more of the tags below in the name of the map#==============================================================================#==============================================================================# Map name tags: (in order of Z coordinate from top to bottom)# ------------------------------------------------------------## [F2 filename x-speed y-speed opacity blend] → use fog 2# [F1 filename x-speed y-speed opacity blend] → use fog 1# (map layer renders here)# [P1 x-speed y-speed opacity blend] → override normal parallax# [PM map_ID x-speed y-speed] → use map as parallax# [P2 filename x-speed y-speed opacity blend] → use parallax 2# [P3 filename x-speed y-speed opacity blend] → use parallax 3## For Battle Only# ---------------# [BPM map_id] → use map as battleback## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~## filename = parallax filename (MUST be in the 'Parallax' folder)# x-speed = horiz. scroll speed (- = right, + = left, 0 = auto, 999 = none)# y-speed = vert. scroll speed (- = down, + = up, 0 = auto, 999 = none)# opacity = opacity (1 - 255)# blend = blend type (0 = normal, 1 = add, 2 = subtract)# map_id = map ID number (from Map Properties)#==============================================================================#==============================================================================# NOTE: lines 511 - 584 (below) may be deleted if NOT using maps as battlebacks# (deleting that section of code also makes the [BPM map_id] tag invalid)#==============================================================================#==============================================================================# Game_Map#==============================================================================class Game_Map #-------------------------------------------------------------------------- # Public Instance Variables (New) #-------------------------------------------------------------------------- attr_accessor :fog2_name attr_accessor :fog2_speed_x attr_accessor :fog2_speed_y attr_accessor :fog2_opacity attr_accessor :fog2_blend attr_accessor :fog1_name attr_accessor :fog1_speed_x attr_accessor :fog1_speed_y attr_accessor :fog1_opacity attr_accessor :fog1_blend attr_accessor :parallax_opacity attr_accessor :parallax_blend attr_accessor :parallaxmap_id attr_accessor :parallaxmap_speed_x attr_accessor :parallaxmap_speed_y attr_accessor :parallax2_name attr_accessor :parallax2_speed_x attr_accessor :parallax2_speed_y attr_accessor :parallax2_opacity attr_accessor :parallax2_blend attr_accessor :parallax3_name attr_accessor :parallax3_speed_x attr_accessor :parallax3_speed_y attr_accessor :parallax3_opacity attr_accessor :parallax3_blend #-------------------------------------------------------------------------- # Initialize (Mod) #-------------------------------------------------------------------------- alias ow_parallax_initialize initialize unless $@ def initialize ow_parallax_initialize @parallaxmap_id = @parallaxmap_speed_x = @parallaxmap_speed_y = 0 @parallax2_name = @parallax3_name = @fog1_name = @fog2_name = "" @parallax2_speed_x = @parallax3_speed_x = @fog1_speed_x = @fog2_speed_x = 0 @parallax2_speed_y = @parallax3_speed_y = @fog1_speed_y = @fog2_speed_y = 0 @fog1_opacity = @fog2_opacity = @parallax_opacity = 255 @fog1_blend = @fog2_blend = @parallax_blend = 0 @parallax2_opacity = @parallax3_opacity = 255 @parallax2_blend = @parallax3_blend = 0 end #-------------------------------------------------------------------------- # Parallax & Fog Setup (Mod) #-------------------------------------------------------------------------- alias ow_parallax_setup_parallax setup_parallax unless $@ def setup_parallax ow_parallax_setup_parallax mapname = load_data("Data/MapInfos.rvdata")[$game_map.map_id].name mapname.scan(/\[F2 ([\w]+) ([\W\d]+) ([\W\d]+) ([\d]+) ([\d])\]/i) @fog2_name = $1.to_s @fog2_speed_x = $2.to_i @fog2_speed_y = $3.to_i @fog2_opacity = $4.to_i @fog2_blend = $5.to_i @fog2_x = @fog2_y = 0 mapname.scan(/\[F1 ([\w]+) ([\W\d]+) ([\W\d]+) ([\d]+) ([\d])\]/i) @fog1_name = $1.to_s @fog1_speed_x = $2.to_i @fog1_speed_y = $3.to_i @fog1_opacity = $4.to_i @fog1_blend = $5.to_i @fog1_x = @fog1_y = 0 mapname.scan(/\[PM ([\d]+) ([\W\d]+) ([\W\d]+)\]/i) @parallaxmap_id = $1.to_i @parallaxmap_speed_x = $2.to_i @parallaxmap_speed_y = $3.to_i @parallaxmap_x = @parallaxmap_y = 0 if mapname.include?('[P1 ') mapname.scan(/\[P1 ([\W\d]+) ([\W\d]+) ([\d]+) ([\d])\]/i) @parallax_sx = $1.to_i @parallax_sy = $2.to_i @parallax_opacity = $3.to_i @parallax_blend = $4.to_i end mapname.scan(/\[P2 ([\w]+) ([\W\d]+) ([\W\d]+) ([\d]+) ([\d])\]/i) @parallax2_name = $1.to_s @parallax2_speed_x = $2.to_i @parallax2_speed_y = $3.to_i @parallax2_opacity = $4.to_i @parallax2_blend = $5.to_i @parallax2_x = @parallax2_y = 0 mapname.scan(/\[P3 ([\w]+) ([\W\d]+) ([\W\d]+) ([\d]+) ([\d])\]/i) @parallax3_name = $1.to_s @parallax3_speed_x = $2.to_i @parallax3_speed_y = $3.to_i @parallax3_opacity = $4.to_i @parallax3_blend = $5.to_i @parallax3_x = @parallax3_y = 0 end #-------------------------------------------------------------------------- # Set Display Position (Mod) #-------------------------------------------------------------------------- alias ow_parallax_set_display_pos set_display_pos unless $@ def set_display_pos(x, y) ow_parallax_set_display_pos(x, y) @parallaxmap_x = @parallax2_x = @parallax3_x = @fog1_x = @fog2_x = x @parallaxmap_y = @parallax2_y = @parallax3_y = @fog1_y = @fog2_y = y end #-------------------------------------------------------------------------- # Calculate X coordinate for parallax display (Rewrite) #-------------------------------------------------------------------------- def calc_parallax_x(bitmap, layer = 0) case layer when -3 # Parallax 3 calc = @parallax3_x xloop = (@parallax3_speed_x != 999) mult = (@parallax3_speed_x == 0) ? 0.2 : 0.5 when -2 # Parallax 2 calc = @parallax2_x xloop = (@parallax2_speed_x != 999) mult = (@parallax2_speed_x == 0) ? 0.35 : 0.5 when -1 # Parallax Map calc = @parallaxmap_x xloop = (@parallaxmap_speed_x != 999) mult = 0.5 when 0 # Normal Parallax calc = @parallax_x xloop = @parallax_loop_x mult = (@parallax_sx == 0) ? 1 : 0.5 when 1 # Fog 1 calc = @fog1_x xloop = (@fog1_speed_x != 999) mult = (@fog1_speed_x == 0) ? 2.5 : 0.5 when 2 # Fog 2 calc = @fog2_x xloop = (@fog2_speed_x != 999) mult = (@fog2_speed_x == 0) ? 3 : 0.5 end if bitmap == nil and layer != -1 return 0 elsif xloop return calc / (16 / mult) elsif loop_horizontal? and layer != -1 return 0 else return calc / 8 if layer == -1 w1 = bitmap.width - Graphics.width w2 = @map.width * 32 - Graphics.width if w1 <= 0 or w2 <= 0 return 0 else return calc * w1 / w2 / 8 end end end #-------------------------------------------------------------------------- # Calculate Y coordinate for parallax display (Rewrite) #-------------------------------------------------------------------------- def calc_parallax_y(bitmap, layer = 0) case layer when -3 # Parallax 3 calc = @parallax3_y yloop = (@parallax3_speed_y != 999) mult = (@parallax3_speed_y == 0) ? 0.2 : 0.5 when -2 # Parallax 2 calc = @parallax2_y yloop = (@parallax2_speed_y != 999) mult = (@parallax2_speed_y == 0) ? 0.35 : 0.5 when -1 # Parallax Map calc = @parallaxmap_y yloop = (@parallaxmap_speed_y != 999) mult = 0.5 when 0 # Normal Parallax calc = @parallax_y yloop = @parallax_loop_y mult = (@parallax_sy == 0) ? 1 : 0.5 when 1 # Fog 1 calc = @fog1_y yloop = (@fog1_speed_y != 999) mult = (@fog1_speed_y == 0) ? 2.5 : 0.5 when 2 # Fog 2 calc = @fog2_y yloop = (@fog2_speed_y != 999) mult = (@fog2_speed_y == 0) ? 3 : 0.5 end if bitmap == nil and layer != -1 return 0 elsif yloop return calc / (16 / mult) elsif loop_vertical? and layer != -1 return 0 else return calc / 8 if layer == -1 h1 = bitmap.height - Graphics.height h2 = @map.height * 32 - Graphics.height if h1 <= 0 or h2 <= 0 return 0 else return calc * h1 / h2 / 8 end end end #-------------------------------------------------------------------------- # Scroll Down (Mod) #-------------------------------------------------------------------------- alias ow_parallax_scroll_down scroll_down unless $@ def scroll_down(distance) ow_parallax_scroll_down(distance) if loop_vertical? @fog2_y += distance @fog1_y += distance @parallaxmap_y += distance @parallax2_y += distance @parallax3_y += distance else last_y = @display_y h = (Graphics.height / 32) @display_y = [@display_y + distance, (height - h) * 256].min @fog2_y += @display_y - last_y @fog1_y += @display_y - last_y @parallaxmap_y += @display_y - last_y @parallax2_y += @display_y - last_y @parallax3_y += @display_y - last_y end end #-------------------------------------------------------------------------- # Scroll Left (Mod) #-------------------------------------------------------------------------- alias ow_parallax_scroll_left scroll_left unless $@ def scroll_left(distance) ow_parallax_scroll_left(distance) if loop_horizontal? @fog2_x -= distance @fog1_x -= distance @parallaxmap_x -= distance @parallax2_x -= distance @parallax3_x -= distance else last_x = @display_x @display_x = [@display_x - distance, 0].max @fog2_x += @display_x - last_x @fog1_x += @display_x - last_x @parallaxmap_x += @display_x - last_x @parallax2_x += @display_x - last_x @parallax3_x += @display_x - last_x end end #-------------------------------------------------------------------------- # Scroll Right (Mod) #-------------------------------------------------------------------------- alias ow_parallax_scroll_right scroll_right unless $@ def scroll_right(distance) ow_parallax_scroll_right(distance) if loop_horizontal? @fog2_x += distance @fog1_x += distance @parallaxmap_x += distance @parallax2_x += distance @parallax3_x += distance else last_x = @display_x w = (Graphics.width / 32) @display_x = [@display_x + distance, (width - w) * 256].min @fog2_x += @display_x - last_x @fog1_x += @display_x - last_x @parallaxmap_x += @display_x - last_x @parallax2_x += @display_x - last_x @parallax3_x += @display_x - last_x end end #-------------------------------------------------------------------------- # Scroll Up (Mod) #-------------------------------------------------------------------------- alias ow_parallax_scroll_up scroll_up unless $@ def scroll_up(distance) ow_parallax_scroll_up(distance) if loop_vertical? @fog2_y -= distance @fog1_y -= distance @parallaxmap_y -= distance @parallax2_y -= distance @parallax3_y -= distance else last_y = @display_y @display_y = [@display_y - distance, 0].max @fog2_y += @display_y - last_y @fog1_y += @display_y - last_y @parallaxmap_y += @display_y - last_y @parallax2_y += @display_y - last_y @parallax3_y += @display_y - last_y end end #-------------------------------------------------------------------------- # Update Parallax (Mod) #-------------------------------------------------------------------------- alias ow_parallax_update_parallax update_parallax unless $@ def update_parallax ow_parallax_update_parallax @fog2_x += @fog2_speed_x * 4 @fog2_y += @fog2_speed_y * 4 @fog1_x += @fog1_speed_x * 4 @fog1_y += @fog1_speed_y * 4 @parallaxmap_x += @parallaxmap_speed_x * 4 @parallaxmap_y += @parallaxmap_speed_y * 4 @parallax2_x += @parallax2_speed_x * 4 @parallax2_y += @parallax2_speed_y * 4 @parallax3_x += @parallax3_speed_x * 4 @parallax3_y += @parallax3_speed_y * 4 endend#==============================================================================# Spriteset_Map#==============================================================================class Spriteset_Map #-------------------------------------------------------------------------- # Create Tilemap (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssm_create_tilemap create_tilemap unless $@ def create_tilemap @parallax2 = Plane.new(@viewport1) @parallax2.z = -200 @parallax2.opacity = $game_map.parallax2_opacity @parallax2.blend_type = $game_map.parallax2_blend @parallax3 = Plane.new(@viewport1) @parallax3.z = -300 @parallax3.opacity = $game_map.parallax3_opacity @parallax3.blend_type = $game_map.parallax3_blend create_parallax_map create_parallax ow_parallax_ssm_create_tilemap end #-------------------------------------------------------------------------- # Create Parallax (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssm_create_parallax create_parallax unless $@ def create_parallax return unless @fog2.nil? ow_parallax_ssm_create_parallax @parallax.z = 0 @parallax.opacity = $game_map.parallax_opacity @parallax.blend_type = $game_map.parallax_blend @fog_viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @fog_viewport.z = 200 @fog2 = Plane.new(@fog_viewport) @fog2.z = 200 @fog2.opacity = $game_map.fog2_opacity @fog2.blend_type = $game_map.fog2_blend @fog1 = Plane.new(@fog_viewport) @fog1.z = 100 @fog1.opacity = $game_map.fog1_opacity @fog1.blend_type = $game_map.fog1_blend end #-------------------------------------------------------------------------- # Create Parallax Map (New) #-------------------------------------------------------------------------- def create_parallax_map pm_id = $game_map.parallaxmap_id if pm_id == 0 @parallax_map = nil else @parallax_map = Tilemap.new(@viewport1) @parallax_map.bitmaps[0] = Cache.system("TileA1") @parallax_map.bitmaps[1] = Cache.system("TileA2") @parallax_map.bitmaps[2] = Cache.system("TileA3") @parallax_map.bitmaps[3] = Cache.system("TileA4") @parallax_map.bitmaps[4] = Cache.system("TileA5") @parallax_map.bitmaps[5] = Cache.system("TileB") @parallax_map.bitmaps[6] = Cache.system("TileC") @parallax_map.bitmaps[7] = Cache.system("TileD") @parallax_map.bitmaps[8] = Cache.system("TileE") @pmap = load_data(sprintf("Data/Map%03d.rvdata", pm_id)) data = @pmap.data @parallax_map.map_data = data end end #-------------------------------------------------------------------------- # Dispose of Parallax (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssm_dispose_parallax dispose_parallax unless $@ def dispose_parallax ow_parallax_ssm_dispose_parallax @fog2.dispose @fog1.dispose @fog_viewport.dispose if @parallax_map != nil @parallax_map.dispose @parallax_map = nil end @parallax2.dispose @parallax3.dispose end #-------------------------------------------------------------------------- # Update Parallax (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssm_update_parallax update_parallax unless $@ def update_parallax ow_parallax_ssm_update_parallax @fog_viewport.update if @fog2_name != $game_map.fog2_name @fog2_name = $game_map.fog2_name if @fog2.bitmap != nil @fog2.bitmap.dispose @fog2.bitmap = nil end if @fog2_name != "" @fog2.bitmap = Cache.parallax(@fog2_name) end Graphics.frame_reset end @fog2.ox = $game_map.calc_parallax_x(@fog2.bitmap, 2) @fog2.oy = $game_map.calc_parallax_y(@fog2.bitmap, 2) if @fog1_name != $game_map.fog1_name @fog1_name = $game_map.fog1_name if @fog1.bitmap != nil @fog1.bitmap.dispose @fog1.bitmap = nil end if @fog1_name != "" @fog1.bitmap = Cache.parallax(@fog1_name) end Graphics.frame_reset end @fog1.ox = $game_map.calc_parallax_x(@fog1.bitmap, 1) @fog1.oy = $game_map.calc_parallax_y(@fog1.bitmap, 1) if @parallax_map != nil @parallax_map.ox = $game_map.calc_parallax_x(nil, -1) @parallax_map.oy = $game_map.calc_parallax_y(nil, -1) @parallax_map.update end if @parallax2_name != $game_map.parallax2_name @parallax2_name = $game_map.parallax2_name if @parallax2.bitmap != nil @parallax2.bitmap.dispose @parallax2.bitmap = nil end if @parallax2_name != "" @parallax2.bitmap = Cache.parallax(@parallax2_name) end Graphics.frame_reset end @parallax2.ox = $game_map.calc_parallax_x(@parallax2.bitmap, -2) @parallax2.oy = $game_map.calc_parallax_y(@parallax2.bitmap, -2) if @parallax3_name != $game_map.parallax3_name @parallax3_name = $game_map.parallax3_name if @parallax3.bitmap != nil @parallax3.bitmap.dispose @parallax3.bitmap = nil end if @parallax3_name != "" @parallax3.bitmap = Cache.parallax(@parallax3_name) end Graphics.frame_reset end @parallax3.ox = $game_map.calc_parallax_x(@parallax3.bitmap, -3) @parallax3.oy = $game_map.calc_parallax_y(@parallax3.bitmap, -3) endend################################################################################ NOTE: All code from here on may be deleted if NOT using maps as battlebacks################################################################################==============================================================================# Spriteset_Battle#==============================================================================class Spriteset_Battle #-------------------------------------------------------------------------- # Create Battleback Sprite (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssb_create_battleback create_battleback unless $@ def create_battleback ow_parallax_ssb_create_battleback @battleback_sprite.visible = false create_battle_parallax_map end #-------------------------------------------------------------------------- # Create Battlefloor Sprite (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssb_create_battlefloor create_battlefloor unless $@ def create_battlefloor ow_parallax_ssb_create_battlefloor @battlefloor_sprite.visible = false end #-------------------------------------------------------------------------- # Dispose (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssb_dispose dispose unless $@ def dispose if @battle_parallax_map != nil @battle_parallax_map.dispose @battle_parallax_map = nil end ow_parallax_ssb_dispose end #-------------------------------------------------------------------------- # Update (Mod) #-------------------------------------------------------------------------- alias ow_parallax_ssb_update update unless $@ def update ow_parallax_ssb_update if @battle_parallax_map != nil @battle_parallax_map.update end end #-------------------------------------------------------------------------- # Create Battle Parallax Map (New) #-------------------------------------------------------------------------- def create_battle_parallax_map map_name = load_data("Data/MapInfos.rvdata")[$game_map.map_id].name map_name.scan(/\[BPM ([\W\d]+)\]/i) bparallax_map_id = $1.to_i if bparallax_map_id == 0 @battle_parallax_map = nil else @battle_parallax_map = Tilemap.new(@viewport1) @battle_parallax_map.bitmaps[0] = Cache.system("TileA1") @battle_parallax_map.bitmaps[1] = Cache.system("TileA2") @battle_parallax_map.bitmaps[2] = Cache.system("TileA3") @battle_parallax_map.bitmaps[3] = Cache.system("TileA4") @battle_parallax_map.bitmaps[4] = Cache.system("TileA5") @battle_parallax_map.bitmaps[5] = Cache.system("TileB") @battle_parallax_map.bitmaps[6] = Cache.system("TileC") @battle_parallax_map.bitmaps[7] = Cache.system("TileD") @battle_parallax_map.bitmaps[8] = Cache.system("TileE") data = load_data(sprintf("Data/Map%03d.rvdata", bparallax_map_id)).data @battle_parallax_map.map_data = data @battle_parallax_map.ox = 0 @battle_parallax_map.oy = 0 end endend
Last edited by a moderator:
