Today, 05:37 AM
(This post was last modified: 1 hour ago by DerVVulfman.)
Poccil Map Zoom
Version: 1.1
Based on Trebor777's Map Zoom
The Re-Envisioned Game Set
Version: 1.1
Based on Trebor777's Map Zoom
The Re-Envisioned Game Set
(Video Footage)
Introduction
The original Map Zoom script was written by Trebor777, though it was written for a totally different Tilemap script. In respect to Trebor777, the instructions are still written both French and English.
FR: Ce script vous permet d'effectuer un zoom avant ou arrière sur un endroit précis de la carte.
EN: This script allow you to zoom in or out on a specific map location.
Features
- Can set zoom speed/duration
- Can set zoom magnification
- Target a specific tile or it defaults to the player
Screenshots
None.
Demo
BOX.COM LINK Look for the Download link in the top right of the screen
Script
The Map Zoom Script
Code:
#==============================================================================
# ** Poccil Map Zoom
# Une réécriture de Map Zoom v1.1 par Trebor777 pour Poccil's Tilemap
# A rewrite of Map Zoom v1.1 by Trebor777 for Poccil's Tilemap
#------------------------------------------------------------------------------
# Version 1.1
# Edit by DerVVulfman
# 02-22-2025 (MM-DD-YYYY)
# RGSS / RPGMaker XP / RUBY 2.7 Compliant
#==============================================================================
#
#
# INTRODUCTION:
# =============
# FR: Ce script vous permet d'effectuer un zoom avant ou arrière sur un
# endroit précis de la carte.
#
# EN: This script allow you to zoom in or out on a specific map location.
#
#
# --------------------------------------------------------------------------
#
# In respect to Trebor777, the instructions are still written both French
# and English.
#
# En ce qui concerne Trebor777, les instructions sont toujours rédigées en
# français et en anglais.
#
# --------------------------------------------------------------------------
#
#
# INSTRUCTIONS:
# =============
# FR: Placez ce script sous le script de Poccil et au-dessus de Main.
# Configurer selon les besoins (Nouveau)
# Utiliser 1 des 2 commandes dans un appel de script :
# . $game_map.start_zoom(scale, speed, x, y)
# . zoom(scale, speed, x, y)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# scale: Valeur du zoom à atteindre (de 0,1 à l'infini)
# speed: Vitesse du zoom (de 0,1 à 10,0)
# x & y: Emplacement de la tuile . S'il est vide, il prend par défaut
# le player
#
# EN: Place this script below Poccil's script and above Main.
# Configure as needed (New)
# Use 1 of the 2 commands in a script call:
# . $game_map.start_zoom(scale, speed, x, y)
# . zoom(scale, speed, x, y)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# scale: Zoom value to reach (from 0.1 to infinity)
# speed: Zoom speed (from 0.1 to 10.0)
# x & y: Target Tile Location. If empty, it defaults to the player
#
#
#
# NOTES:
# ======
# FR: L'utilisation de la fonction de zoom à proximité des limites de la carte
# pose des problèmes, et l'appareil photo ne se concentre pas exactement
# sur sa cible.
#
# S'il est utilisé avec 'Screen Size for RMXP', supprimez ou désactivez le
# module ScrnSize de ce script. Screen Size for RMXP dispose d'une version
# plus complète qu'il est préférable d'utiliser.
#
# EN: There are issues attempting to use the zoom feature when near map
# borders, and the camera will not exactly focus on its target.
#
# If used with 'Screen Size for RMXP', remove or disable this script's
# ScrnSize module. Screen Size for RMXP has a more extensive version you
# would rather put to use.
#
#
#
# CONFIGURATION (New/Nouveau):
# ============================
# FR: Ce script est conçu pour fonctionner avec une version réécrite du Tilemap
# de Poccil. Parce qu'il peut tirer parti des scripts qui peuvent modifier
# la résolution de l'écran, ce script dispose désormais d'une section de
# configuration simple. Il vous suffit de définir la taille de l'écran de
# votre jeu. Valeur par défaut : 640 x 480.
#
# EN: This script is made to work with a rewritten version of Poccil's Tilemap.
# Because it can take advantage of scripts that can change the screen
# resolution, this script now has a simple configuration section. You
# only need to set the screen size of your game. Default: 640 x 480.
#
#
#
# MODIFICATIONS TO CODE / MODIFICATIONS DU CODE:
# ==============================================
#
# Alias / attached code / code attaché
# (à partir du SDK RMXP / from the RMXP SDK)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Game_Map: setup_scroll, update_scrolling
#
# Overwritten code / Code remplacé
# (Les scripts par défaut / The default scripts
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Game_Map: scroll_down, scroll_right
# * Game_Character: screen_x, screen_y, screen_z
# * Game_Player: center (Et les constantes CENTER, And the CENTER constants)
#
# Overwritten code / Code remplacé
# (à partir du SDK RMXP / from the RMXP SDK)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Spriteset_Map: init_viewports, update_character_sprites
#
#
#
# VERSION:
# ========
# Version 1.0 - FR: Première version
# EN: First release
#
# Version 1.1 - FR: Code adapté à la nouvelle classe tilemap de SephirothSpawn.
# EN: Code adapted to the new tilemap class by SephirothSpawn.
#
# --------------------------------------------------------------------------
#
# NEW VERSION:
# ============
# Version 1.0 - FR: Première version du script Tilemap de Poccil
# EN: First version for Poccil's Tilemap script
#
# Version 1.1 - FR: Correction des profondeurs z qui affectaient les priorités
# des tuiles
# EN: Correction in z-Depths that affected tile priorities
#
#
#==============================================================================
#
# CREDITS
# =======
# Merci à Trebor777 pour le script original de zoom sur la carte, et merci à
# Mel de Save-Point.Org pour avoir remarqué un problème mineur qui affectait
# les priorités des tuiles.
#
# Thanks to Trebor777 for the original map zoom script, and thanks to Mel of
# Save-Point.Org for noticing a minor issue that affected tile priorities.
#
#
#==============================================================================
#
# TERMS OF USE / CONDITIONS D'UTILISATION:
# ========================================
#
# L'utilisation est libre, même dans les produits commerciaux. Cependant, il
# est nécessaire de mentionner mon nom, celui de Trebor777 et celui de Mel.
#
# Free for use, even in commercial products. However, due credit to myself,
# Trebor777 and Mel is a necessity.
#
#==============================================================================
=begin
#==============================================================================
# ** ScrnSize
#------------------------------------------------------------------------------
# This module handles the adjustable screen size for games that utilize
# resolution scripts to alter game window dimensions.
#==============================================================================
module ScrnSize
# GAME SCREEN RESOLUTION
# ======================
# La nécessité absolue... ici, vous définissez les dimensions de l'écran de
# votre jeu. Dans un système normal, ces dimensions sont codées en dur à
# 640x480, mais cette section permet de les ajuster si vous utilisez un script
# de résolution.
# <- IL EST RECOMMANDÉ QUE LES VALEURS DÉFINIES SOIENT DES MULTIPLES DE 32! ->
#
# The absolute necessity... here, you define the dimensions of your game's
# display. A normal system would have this hardcoded to 640x480, but this
# section makes it adjustable if you have a resolution script in use.
# <----- IT IS RECOMMENDED T HAT THE DEFINED VALUES BE MULTIPLES OF 32! ----->
# ----------------------------------------------------------------------------
#
Width = 1280 # Largeur et hauteur de la zone d'écran en pixels.
Height = 736 # Screen area width and height in pixels.
# Width = 640
# Height = 480
# Width = 320
# Height = 200
end
=end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ** ATTACHED CONTENT SECTION
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# Alias Listings
#--------------------------------------------------------------------------
alias zoom_setup_scroll setup_scroll
alias zoom_update_scrolling update_scrolling
#--------------------------------------------------------------------------
# * Setup Scroll
#--------------------------------------------------------------------------
def setup_scroll
setup_zoom # Execute new material
zoom_setup_scroll # Perform the original method
end
#--------------------------------------------------------------------------
# * Update Scrolling
#--------------------------------------------------------------------------
def update_scrolling
update_zooming # Execute new material
zoom_update_scrolling # Perform the original method
end
#--------------------------------------------------------------------------
# ** NEW CONTENT SECTION
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Setup Zoom
#--------------------------------------------------------------------------
def setup_zoom
# Initialize zoom information
@zoom_rest = 0
@zoom_speed = 2
end
#--------------------------------------------------------------------------
# * Start Zoom
# scale : zoom value to reach
# speed : zoom speed
# x : camera x coordinates during zoom
# y : camera y coordinates during zoom
#--------------------------------------------------------------------------
def start_zoom(scale=1.0, speed=2, x=nil, y=nil)
#
# Exit if already at the defined scale
return if @tilemap_zoom_x == scale
#
# Keeping values in range
speed = 0.1 if speed < 0.1 # Zoom speed no slower than 0.1
speed = 10.0 if speed > 10.0 # Zoom speed no greater than 10
@x_zoom = (x.nil?) ? $game_player.x : x # Player X coord if none defined
@y_zoom = (y.nil?) ? $game_player.y : y # Player Y coord if none defined
#
# Copy scale value for end of zoom
@scale_end = scale
#
# Adjust zoom position
min_x = (tiles_across / 2) + 1
min_y = (tiles_down / 2) + 1
max_x = (width - (tiles_across / 2)) - 1
max_y = (height - (tiles_down / 2)) - 1
#
# Keep Zooms within the defined boundaries
@x_zoom = min_x if @x_zoom < min_x
@y_zoom = min_y if @y_zoom < min_y
@x_zoom = max_x if @x_zoom > max_x
@y_zoom = max_y if @y_zoom > max_y
#
# Set differerence between current and supplied zoom
@zoom_rest = (scale - @tilemap_zoom_x).abs
#
# Set duration for change
@zoom_speed = speed * ((scale - @tilemap_zoom_x) / @zoom_rest)
#
# Begin initial center
$game_player.center(@x_zoom, @y_zoom)
#
end
#--------------------------------------------------------------------------
# * Determine if Zooming
#--------------------------------------------------------------------------
def zooming?
return @zoom_rest > 0
end
#--------------------------------------------------------------------------
# * Update Zooming
#--------------------------------------------------------------------------
def update_zooming
#
# Exit unless zooming
return if @zoom_rest <= 0
#
# Change from zoom speed to focus in map coordinates
focus = 0.02 * @zoom_speed
#
# Execute zooming
@tilemap_zoom_x += focus
@tilemap_zoom_y += focus
#
# Subtract focus zoomed
@zoom_rest -= focus.abs
#
# Exit if zoom had completed
return zooming_end if @zoom_rest <= 0
return zooming_end if @scale == @tilemap_zoom_x
#
# Center focus on subject/coordinates passed
$game_player.center(@x_zoom, @y_zoom)
#
end
#--------------------------------------------------------------------------
# * End Zoom and set values to one decimal position
#--------------------------------------------------------------------------
def zooming_end
#
# Ensure the tilemap is at its final scale
@tilemap_zoom_x = @scale_end
@tilemap_zoom_y = @scale_end
#
# Set camera center on zoom focus
$game_player.center(@x_zoom, @y_zoom) if @scale_end == 1.0
#
# Flag zoom rest
@zoom_rest = 0
#
end
#--------------------------------------------------------------------------
# * Get number of tiles horizontally
# (NEW)
#--------------------------------------------------------------------------
def tiles_across
return ScrnSize::Width / 32
end
#--------------------------------------------------------------------------
# * Get number of tiles vertically
# (NEW)
#--------------------------------------------------------------------------
def tiles_down
return ScrnSize::Height / 32
end
#--------------------------------------------------------------------------
# ** MODDED/REWRITE CODE SECTION
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
new_height = self.height * @tilemap_zoom_y
mult = 128 / tilemap_zoom_y
@display_y = [@display_y + distance, (new_height - tiles_down) * mult].min
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
new_width = self.width * @tilemap_zoom_x
mult = 128 / tilemap_zoom_x
@display_x = [@display_x + distance, (new_width - tiles_across) * mult].min
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ** MODDED/REWRITE CODE SECTION
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Get Screen X-Coordinates
#--------------------------------------------------------------------------
def screen_x
#
# Acquire map display and zoom figures
display_x = $game_map.display_x
tx_zoom = $game_map.tilemap_zoom_x
#
# Get and return screen coordinates from real ones based on acquired data
new_x = @real_x - display_x + 3
return (new_x / 4 + 16) * tx_zoom
#
end
#--------------------------------------------------------------------------
# * Get Screen Y-Coordinates
#--------------------------------------------------------------------------
def screen_y
#
# Acquire map display and zoom figures
display_y = $game_map.display_y
ty_zoom = $game_map.tilemap_zoom_y
#
# Get screen coordinates from real ones based on acquired data
new_y = @real_y - display_y + 3
y = (new_y / 4 + 32) * ty_zoom
#
# Make y-coordinate smaller via jump count
if @jump_count >= @jump_peak
n = @jump_count - @jump_peak
else
n = @jump_peak - @jump_count
end
#
# Exit with y coordinates adjusted by jump count
return y - (@jump_peak * @jump_peak - n * n) / 2
#
end
#--------------------------------------------------------------------------
# * Get Screen Z-Coordinates
#--------------------------------------------------------------------------
def screen_z(height = 0)
#
# If display flag on closest surface is ON
if @always_on_top
# 999, unconditional
return 999
end
#
# Acquire map display, zoom figures and priorities if valid
display_y = $game_map.display_y
ty_zoom = $game_map.tilemap_zoom_y
prio = (@tile_id > 0) ? $game_map.priorities[@tile_id] : 0
#
# Get screen coordinates from real ones based on acquired data
new_y = @real_y - display_y + 3
z = (new_y / 4 + 32) * ty_zoom
#
# Calculate depth increase based on tile priority or non-tile height excess
addtl = (@tile_id > 0) ? (prio * 32 * ty_zoom ) : ((height > 32) ? 31 : 0)
#
# Exit with adjusted z coordinates
return z + addtl
#
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ** MODDED/REWRITE CODE SECTION
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Instance Variables
#--------------------------------------------------------------------------
CENTER_X = ((ScrnSize::Width/2) - 16) * 4 # Center screen x-coordinate * 4
CENTER_Y = ((ScrnSize::Height/2) - 16) * 4 # Center screen y-coordinate * 4
@center_x = CENTER_X # Copy of x-center for edit
@center_y = CENTER_Y # Copy of y-center for edit
#--------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#--------------------------------------------------------------------------
def center(x, y)
#
# Acquire map zoom and visible tile area from Game_Map
zoom_x = $game_map.tilemap_zoom_x
zoom_y = $game_map.tilemap_zoom_y
tiles_across = $game_map.tiles_across
tiles_down = $game_map.tiles_down
#
# Re-evaluate center x/y coordinates based on zoom
@center_x = ((ScrnSize::Width/2) / zoom_x - 16) * 4
@center_y = ((ScrnSize::Height/2) / zoom_y - 16) * 4
#
# Set max value
max_x = ($game_map.width - tiles_across) * 128
max_y = ($game_map.height - tiles_down) * 128
#
# Change max scale to accomodate zoom operations
if $game_map.zooming?
max_x = ($game_map.width) * 128
max_y = ($game_map.height) * 128
end
#
# Almost untouched
$game_map.display_x = [0, [x * 128 - @center_x, max_x].min].max
$game_map.display_y = [0, [y * 128 - @center_y, max_y].min].max
#
end
#--------------------------------------------------------------------------
# ** NEW CONTENT SECTION (overwriting Game_Character scrolling)
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Scroll Down
#--------------------------------------------------------------------------
def update_scroll_down(last_real_y)
#
# If character moves down and is positioned lower than the screen's center
if @real_y > last_real_y and @real_y - $game_map.display_y > @center_y
# Scroll map down
$game_map.scroll_down(@real_y - last_real_y)
end
#
end
#--------------------------------------------------------------------------
# * Scroll Left
#--------------------------------------------------------------------------
def update_scroll_left(last_real_x)
#
# If character moves left and is placed more left on-screen than center
if @real_x < last_real_x and @real_x - $game_map.display_x < @center_x
# Scroll map left
$game_map.scroll_left(last_real_x - @real_x)
end
#
end
#--------------------------------------------------------------------------
# * Scroll Right
#--------------------------------------------------------------------------
def update_scroll_right(last_real_x)
#
# If character moves right and is placed more right on-screen than center
if @real_x > last_real_x and @real_x - $game_map.display_x > @center_x
# Scroll map right
$game_map.scroll_right(@real_x - last_real_x)
end
#
end
#--------------------------------------------------------------------------
# * Scroll Up
#--------------------------------------------------------------------------
def update_scroll_up(last_real_y)
#
# If character moves up and is positioned higher than the screen's center
if @real_y < last_real_y and @real_y - $game_map.display_y < @center_y
# Scroll map up
$game_map.scroll_up(last_real_y - @real_y)
end
#
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ** MODDED/REWRITE CODE SECTION (SDK method overwrites)
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Viewport Initialization
#--------------------------------------------------------------------------
def init_viewports
#
# Acquire resolution sizes
rwidth = ScrnSize::Width
rheight = ScrnSize::Height
#
# Make viewports using resolution size
@viewport1 = Viewport.new(0, 0, rwidth, rheight)
@viewport2 = Viewport.new(0, 0, rwidth, rheight)
@viewport3 = Viewport.new(0, 0, rwidth, rheight)
@viewport2.z = 200
@viewport3.z = 5000
#
end
#--------------------------------------------------------------------------
# * Update Character Sprites
#--------------------------------------------------------------------------
def update_character_sprites
#
# Update character sprites
for sprite in @character_sprites
sprite.zoom_x = $game_map.tilemap_zoom_x # Apply new x scale for sprite
sprite.zoom_y = $game_map.tilemap_zoom_y # Apply new y scale for sprite
sprite.update # Update sprite with new scale
end
#
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * Zoom
# scale : zoom value to reach
# speed : zoom speed
# x : camera x coordinates during zoom
# y : camera y coordinates during zoom
#--------------------------------------------------------------------------
def zoom(scale=1.0, speed=1, x=nil, y=nil)
#
# Assume game player coordinates of x and y are empty
x = $game_player.x if x.nil?
y = $game_player.y if y.nil?
#
# Pass into game map if not already executing zoom
$game_map.start_zoom(scale, speed, x, y) if !$game_map.zooming?
#
end
end
Instructions
Plenty, and in the script.
FAQ
Made in conjunction with Screen Size for RMXP and Poccil's Tilemap Rewrite. It was originally designed for the Tilemap Script by SephirothSpawn, but that Tilemap script was not completed.
If used with 'Screen Size for RMXP', remove or disable this script's ScrnSize module. Screen Size for RMXP has a more extensive version you would rather put to use.
There are issues attempting to use the zoom feature when near map borders, and the camera will not exactly focus on its target.
Compatibility
Designed for RPGMaker XP. Adapted for use with Poccil's Tilemap. RUBY 2.7 Compliant
Will require both Poccil's Tilemap
Will require either the RMXP SDK v2.3 or newer, or a collection of RMXP SDK methods (included in the demo).
Credits and Thanks
Thanks go to Trebor777 for the bulk of the script, and thanks to Poccil for the Tilemap script that this script adapts.
Terms and Conditions
Free for use, even in commercial products. However, due credit to both myself and Trebor777 is a necessity.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links