FG7 - Easy Parallax Map Lock

Easy Parallax Map Lock
By: FamilyGamer7​

Introduction
Quick and easy script snippet to lock the tile(s) and parallax background together. (Inspiration from Yanfly - Parallax Lock script)

Features
Locks the Parallax background with the tiles when moving on screen and you will have the ability to turn the script functionality "Off/On" during the game with a script call.

Screenshot(s)
- Not Needed -

Script
Spoiler: FG7 - Easy Parallax Map Lock
Ruby:
#==============================================================================
# Title: Easy Parallax Map Lock
# Author: FamilyGamer7 (FG7)
# Version: 1.0
# Engine: RPG Maker VX Ace
# (Inspiration from Yanfly - Parallax Lock script)
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created script
#==============================================================================
# ** Description |
# ----------------
# Quick and easy script snippet to lock the tile(s) and parallax together.
# (Locks the Parallax background with the tiles when moving on screen)
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Usage |
# ----------
# * Plug & Play
#
# By default, this parallax map lock will be set as ON. Feel free to turn off
# the script functionality with the script call(s) below.
#
# - Script calls provides ability for ON/OFF functionality during game.
#
# To turn OFF parallax map lock:
# $game_system.parallax_map_lock_off = true
#
# To turn ON parallax map lock:
# $game_system.parallax_map_lock_off = false
#==============================================================================

#==============================================================================
# ** Module: FG7::Easy_Parallax_Map_Lock
#------------------------------------------------------------------------------
#  This modules creates a static variable to be used within the script.
#==============================================================================

module FG7
  module Easy_Parallax_Map_Lock
 
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
 
    # Sets the value for the $game_switch used for the parallax map lock
    Parallax_Map_Lock_Switch = 39
    
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================

  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * New Method: parallax_map_lock_off (Flag to turn on/off during game)
  #--------------------------------------------------------------------------
  def parallax_map_lock_off=(string)
    @parallax_map_lock_off = string
    $game_switches[FG7::Easy_Parallax_Map_Lock::Parallax_Map_Lock_Switch] = @parallax_map_lock_off
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Override Method: Calculate X Coordinate of Parallax Display Origin
  #--------------------------------------------------------------------------
  alias :fg7_easy_parallax_map_lock_parallax_ox :parallax_ox
  def parallax_ox(bitmap)
    return @display_x * 32 if $game_switches[FG7::Easy_Parallax_Map_Lock::Parallax_Map_Lock_Switch] == false
    fg7_easy_parallax_map_lock_parallax_ox(bitmap)
  end
  #--------------------------------------------------------------------------
  # Override Method: Calculate Y Coordinate of Parallax Display Origin
  #--------------------------------------------------------------------------
  alias :fg7_easy_parallax_map_lock_parallax_oy :parallax_oy
  def parallax_oy(bitmap)
    return @display_y * 32 if $game_switches[FG7::Easy_Parallax_Map_Lock::Parallax_Map_Lock_Switch] == false
    fg7_easy_parallax_map_lock_parallax_oy(bitmap)
  end
end

How to Use
Add this script in the script editor under in the "Materials" section and above "Main Process".
The instructions and setup for the script are held within the script header itself. No need to repeat here.

Terms of Use
- Free to use in non-commercial projects and commercial projects
- Feel free to modify and improve the script. Credit is still required.
- Credit FamilyGamer7

Original thread: https://forums.rpgmakerweb.com/threads/fg7-easy-parallax-map-lock.144939/