[RMVXAce] Parallax Mapping

Find scripts to enhance your RPG Maker Games here
Post Reply
User avatar
Crazyninjaguy
Level 1
Posts: 16
Joined: Wed Nov 27, 2019 12:27 pm
Contact:

Game Development Skills

[RMVXAce] Parallax Mapping

#1

Post by Crazyninjaguy » Fri Dec 13, 2019 2:04 pm

Image

Introduction

This is my first brand new script since returning to Game Development!

This script will allow you to use your Parallax maps in RPG Maker VX Ace.
You are able to use a "Base" layer as normal by attaching the parallax to the map in the editor, and the script will look for an Overlay image in the Parallaxes folder to display over the top of players and events.

Instructions

This script locks the parallax available in the editor to the map scroll acting as a background.
The script will then check for a file to use as an "overlay" above the player. This file MUST be named with a suffix of _Overlay and MUST be a .png extension to allow for transparency.

So for example, your Parallax is named "Castle_Town"
The Overlay file must be named "Castle_Town_Overlay"

If no Overlay file is found, it will not be set on the map.

Script
Spoiler
Show

Code: Select all

#===============================================================================
# * Parallax Mapping
# * By Crazyninjaguy
# * https://www.planet-dev.com
# ----------------------------------------------------------------------------
# * This script locks the parallax available in the editor to the map scroll
#   acting as a background.
#   The script will then check for a file to use as an "overlay" above the
#   player. This file MUST be named with a suffix of _Overlay and MUST
#   be a .png extension to allow for transparency.
#
# * So for example, your Parallax is named "Castle_Town"
# * The Overlay file must be named "Castle_Town_Overlay"
# 
# * If no Overlay file is found, it will not be set on the map.
# ----------------------------------------------------------------------------
# * All methods in Spriteset_Map have been aliased so should be compatible with
#   scripts by other developers.
# * The parallax_ox and parallax_oy methods in Game_Map have been overwritten
#===============================================================================

$imported = {} if $imported == nil
$imported["Cng-Parallax"] = true

class Spriteset_Map
  alias cng_parallax_spriteset_create_parallax create_parallax
  def create_parallax
    cng_parallax_spriteset_create_parallax
    @overlay = Plane.new(@viewport1)
    @overlay.z = 201 # Above Character
  end
  alias cng_parallax_spriteset_dispose_parallax dispose_parallax
  def dispose_parallax
    @overlay.bitmap.dispose if @overlay.bitmap
    @overlay.dispose
  end
  alias cng_parallax_spriteset_update_parallax update_parallax
  def update_parallax
    cng_parallax_spriteset_update_parallax
    if @overlay_name != "#{$game_map.parallax_name}_Overlay"
      @overlay_name = "#{$game_map.parallax_name}_Overlay"
      @overlay.bitmap.dispose if @overlay.bitmap
      if FileTest.file?("Graphics/Parallaxes/#{$game_map.parallax_name}_Overlay.png")
        @overlay.bitmap = Cache.parallax(@overlay_name)
      end
      Graphics.frame_reset
    end
    @overlay.ox = ($game_map.display_x * 32)
    @overlay.oy = ($game_map.display_y * 32)
  end
end

#===============================================================================
# * These are overwrites
#===============================================================================
class Game_Map
  def parallax_ox(bitmap)
    @parallax_x = (@display_x * 32)
  end
  def parallax_oy(bitmap)
    @parallax_y = (@display_y * 32)
  end
end
Usage

Available for use in commercial games
PlanetDev Founder/Administrator


Post Reply