Verze: 1.1
Autor: Trebor777
Funkce
Zoomuje specifickou lokaci na mapě.
Instrukce
Umístěte ve script editoru nad řádku Main. Dále je pro tento skript potřeba SDK. Dal?í instrukce jsou obsaženy přímo ve skriptu.
Screenshoty
Nejsou, nebudou. Zkuste demo.

Skript
Map Zoom
- Kód: Vybrat vše
=begin
==============================================================================
** Map_Zoom
------------------------------------------------------------------------------
Trebor777
Version 1.1
14/06/2007
------------------------------------------------------------------------------
* Description FR:
Ce script permet d'effectuer des zoom in et zoom out sur un point pr?cis de
la map.
* Description US:
This script allow you to zoom in or out on a specific map location.
------------------------------------------------------------------------------
* Instructions FR:
Placer le Script sous le SDK et au dessus de Main.
Utiliser 1 des 2 commandes dans un script ou un ?v?nement "appeler un script":
. $game_map.start_zoom(x,y,coef,spd)
. $scene.zoom(x,y,coef,spd) #avec $scene une instance de Scene_Map
x et y: Coordonn?es(pas en pixel) du point ? zoomer/d?zoomer
coef : Valeur du zoom ? atteindre de 0.1, ? l'infini
spd : Vitesse du zoom, la variation est bas?e sur le calcul suivant:
0.2*spd
* Instructions US:
Place The Script Below the SDK and Above Main.
Use 1 of this 2 command in a script or with the event command "Call a script":
. $game_map.start_zoom(x,y,coef,spd)
. $scene.zoom(x,y,coef,spd) #with $scene a Scene_Map instance
x & y: Target Location(not inpixel)to zoom in/out
coef : Zoom value to reach from 0.1, to infinite
spd : Zoom speed, the fluctuation is based on this formula: 0.2*spd
Version 1.1
Code adapted to the new tilemap class.
==============================================================================
=end
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Map_Zoom', 'Trebor777', 1.1, '14-06-2007')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Map_Zoom') and SDK.state('Tilemap')
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
def update_character_sprites
# Update character sprites
for sprite in @character_sprites
sprite.zoom_x=$game_map.tilemap_settings.zoom_x
sprite.zoom_y=$game_map.tilemap_settings.zoom_y
sprite.update
end
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
def zoom(x,y,coef,spd)
if !$game_map.zooming?
$game_map.start_zoom(x,y,coef,spd)
end
end
end
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
alias zoom_setup_scroll setup_scroll
def setup_scroll
setup_zoom
zoom_setup_scroll
end
#--------------------------------------------------------------------------
def setup_zoom
# Initialize scroll information
@zoom_rest = 0
@zoom_speed = 2
end
#--------------------------------------------------------------------------
# * Start Zoom
# focus : zoom value to reach
# speed : zoom speed
#--------------------------------------------------------------------------
def start_zoom(x,y,focus, speed)
@x_zoom=x
@y_zoom=y
@zoom_rest = (focus-@tilemap_settings.zoom_x).abs
@zoom_speed = speed*((focus-@tilemap_settings.zoom_x)/@zoom_rest)
end
#--------------------------------------------------------------------------
# * Determine if Scrolling
#--------------------------------------------------------------------------
def zooming?
return @zoom_rest > 0
end
#--------------------------------------------------------------------------
alias zoom_update_scrolling update_scrolling
def update_scrolling
update_zooming
zoom_update_scrolling
end
#--------------------------------------------------------------------------
def update_zooming
# If zooming
if @zoom_rest > 0
# Change from zoom speed to focus in map coordinates
focus = 0.2 * @zoom_speed
# Execute zooming
@tilemap_settings.zoom_x+=focus
@tilemap_settings.zoom_y+=focus
# Subtract focus zoomed
@zoom_rest -= focus.abs
$game_player.center(@x_zoom,@y_zoom)
end
end
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
@display_y = [@display_y + distance, (self.height*@tilemap_settings.zoom_y - 15) * 128/tilemap_settings.zoom_y].min
end
#--------------------------------------------------------------------------
# * Scroll Left
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_left(distance)
@display_x = [@display_x - distance, 0].max
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
@display_x = [@display_x + distance, (self.width*@tilemap_settings.zoom_x - 20) * 128/tilemap_settings.zoom_x].min
end
#--------------------------------------------------------------------------
# * Scroll Up
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_up(distance)
@display_y = [@display_y - distance, 0].max
end
end
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Get Screen X-Coordinates
#--------------------------------------------------------------------------
def screen_x
# Get screen coordinates from real coordinates and map display position
#return (@real_x) / 4 #+ 16
return (@real_x - $game_map.display_x + 3*$game_map.tilemap_settings.zoom_x) / 4*$game_map.tilemap_settings.zoom_x + 16*$game_map.tilemap_settings.zoom_x
end
#--------------------------------------------------------------------------
# * Get Screen Y-Coordinates
#--------------------------------------------------------------------------
def screen_y
# Get screen coordinates from real coordinates and map display position
y = (@real_y - $game_map.display_y + 3*$game_map.tilemap_settings.zoom_y) / 4*$game_map.tilemap_settings.zoom_y + 32*$game_map.tilemap_settings.zoom_y
# Make y-coordinate smaller via jump count
if @jump_count >= @jump_peak
n = @jump_count - @jump_peak
else
n = @jump_peak - @jump_count
end
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
# Get screen coordinates from real coordinates and map display position
z = (@real_y - $game_map.display_y + 3*$game_map.tilemap_settings.zoom_y) / 4*$game_map.tilemap_settings.zoom_y + 32*$game_map.tilemap_settings.zoom_y
# If tile
if @tile_id > 0
# Add tile priority * 32
return z + $game_map.priorities[@tile_id] * 32*$game_map.tilemap_settings.zoom_y
# If character
else
# If height exceeds 32, then add 31
return z + ((height > 32) ? 31 : 0)
end
end
end
#==============================================================================
# ** Game_Player
#==============================================================================
class Game_Player <Game_Character> 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 positioned more let on-screen than
# center
if @real_x < last_real_x and @real_x - $game_map.display_x <center_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 center
# of the screen
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
#--------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#--------------------------------------------------------------------------
def center(x, y)
@center_x= (320/$game_map.tilemap_settings.zoom_x - 16) * 4 # Center screen x-coordinate * 4
@center_y = (240/$game_map.tilemap_settings.zoom_y - 16) * 4 # Center screen y-coordinate * 4
max_x = ($game_map.width*$game_map.tilemap_settings.zoom_x - 20) * 128/$game_map.tilemap_settings.zoom_x
max_y = ($game_map.height*$game_map.tilemap_settings.zoom_y - 15) * 128/$game_map.tilemap_settings.zoom_y
$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
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
SDK
- Kód: Vybrat vše
#==============================================================================
# ** Tilemap
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 0.91
# 2006-11-06
#------------------------------------------------------------------------------
# * Description :
#
# This script was designed to re-write the default RMXP Hidden Tileset class.
# The script has added zooming, tile size, tone, and a plane effect that can
# be used for a world map script. It also can return a bitmap of all the
# layers merged.
#------------------------------------------------------------------------------
# * Instructions :
#
# Place The Script Below the SDK and Above Main.
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Tilemap', 'SephirothSpawn', 0.91, '2006-11-06')
# Disable Tilemap Script (Suggested Until V 1.0)
SDK.disable('Tilemap')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Tilemap')
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :map
attr_accessor :tilemap_tone
attr_accessor :tilemap_plane
attr_accessor :tilemap_zoom_x
attr_accessor :tilemap_zoom_y
attr_accessor :tilemap_tile_width
attr_accessor :tilemap_tile_height
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_tilemap_gmap_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_tilemap_gmap_init
# Sets Special Tilemap Properties
@tilemap_tone = nil
@tilemap_plane = false
@tilemap_zoom_x = 1.0
@tilemap_zoom_y = 1.0
@tilemap_tile_width = 32
@tilemap_tile_height = 32
end
end
#==============================================================================
# ** Tilemap
#==============================================================================
class Tilemap
#--------------------------------------------------------------------------
# * Animated Autotiles Frames Reset
#--------------------------------------------------------------------------
Animated_Autotiles_Frames = 15
#--------------------------------------------------------------------------
# * Auto-Tiles
#
# Auto-Tile 48 : First Auto-Tile, Constructed of tiles 27, 28, 33, 34
#--------------------------------------------------------------------------
Autotiles = [
[ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34],
[27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ],
[ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34],
[27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ],
[ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12],
[15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
[ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
[39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ],
[ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
[17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
[ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
[37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ]
]
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :layers
attr_accessor :tileset
attr_accessor :autotiles
attr_accessor :map_data
attr_accessor :flash_data
attr_accessor :priorities
attr_accessor :visible
attr_accessor :ox
attr_accessor :oy
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, map = $game_map.map)
# Creates layers
@layers = []
for l in 0...3
layer = ($game_map.tilemap_plane ?
Plane.new(viewport) : Sprite.new(viewport))
layer.bitmap = Bitmap.new(map.width * 32, map.height * 32)
layer.z = l * 150
layer.zoom_x = $game_map.tilemap_zoom_x
layer.zoom_y = $game_map.tilemap_zoom_y
if (tone = $game_map.tilemap_tone).is_a?(Tone)
layer.tone = tone
end
@layers << layer
end
# Sets Tileset Data
@tileset = nil # Refers to Map Tileset Name
@autotiles = [] # Refers to Tileset Auto-Tiles (Actual Auto-Tiles)
@map_data = nil # Refers to 3D Array Of Tile Settings
@flash_data = nil # Refers to 3D Array of Tile Flashdata
@priorities = nil # Refers to Tileset Priorities
@visible = true # Refers to Tilest Visibleness
@ox = 0 # Bitmap Offsets
@oy = 0 # bitmap Offsets
@data = nil # Acts As Refresh Flag
# Sets Specials Tile Properties
@map = map
@tone = $game_map.tilemap_tone
@plane = $game_map.tilemap_plane
@zoom_x = $game_map.tilemap_zoom_x
@zoom_y = $game_map.tilemap_zoom_y
@tile_width = $game_map.tilemap_tile_width
@tile_height = $game_map.tilemap_tile_height
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Dispose Layers (Sprites)
for layer in @layers
layer.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If Data Changes
unless @data == @map_data &&
@tile_width == $game_map.tilemap_tile_width &&
@tile_height == $game_map.tilemap_tile_height
refresh
end
# Tone Change
unless @tone == $game_map.tilemap_tone
@tone = $game_map.tilemap_tone
@tone = Tone.new(0, 0, 0, 0) if @tone.nil?
for layer in @layers
layer.tone = @tone
layer.tone = @tone
end
end
# Zoom Change
unless @zoom_x == $game_map.tilemap_zoom_x
@zoom_x = $game_map.tilemap_zoom_x
for layer in @layers
layer.zoom_x = @zoom_x
layer.zoom_x = @zoom_x
end
end
unless @zoom_y == $game_map.tilemap_zoom_y
@zoom_y = $game_map.tilemap_zoom_y
for layer in @layers
layer.zoom_y = @zoom_y
layer.zoom_y = @zoom_y
end
end
# Update layer Position offsets
for layer in @layers
layer.ox = @ox
layer.oy = @oy
end
# Animated Autotiles
if Graphics.frame_count % Animated_Autotiles_Frames == 0
# Refresh Autotiles
refresh_autotiles
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Saves Map Data
@data = @map_data
# Passes Through All Priorities
for p in 0..5
# Passes Through Layers
for z in 0...@map_data.zsize
# Passes Through X Coordinates
for x in 0...@map_data.xsize
# Passes Through Z Coordinates
for y in 0...@map_data.ysize
# Collects Tile ID
id = @map_data[x, y, z]
# Skip if 0 tile
next if id == 0
# Skip If Priority Doesn't Match
next unless p == @priorities[id]
# Cap Priority to Layer 3
p = 2 if p > 2
# Draw Tile
id < 384 ? draw_autotile(x, y, p, id) : draw_tile(x, y, p, id)
end
end
end
end
end
#--------------------------------------------------------------------------
# * Refresh Auto-Tiles
#--------------------------------------------------------------------------
def refresh_autotiles
# Auto-Tile Locations
autotile_locations = Table.new(@map_data.xsize, @map_data.ysize,
@map_data.zsize)
# Passes Through All Priorities
for p in 0..5
# Passes Through Layers
for z in 0...@map_data.zsize
# Passes Through X Coordinates
for x in 0...@map_data.xsize
# Passes Through Z Coordinates
for y in 0...@map_data.ysize
# Collects Tile ID
id = @map_data[x, y, z]
# Skip if 0 tile
next if id == 0
# Skip If Priority Doesn't Match
next unless p == @priorities[id]
# Cap Priority to Layer 3
p = 2 if p > 2
# If Autotile
if id < 384
# Skip If Non-Animated Tile
next unless @autotiles[id / 48 - 1].width / 96 > 1
# Draw Auto-Tile
draw_autotile(x, y, p, id)
# Save Autotile Location
autotile_locations[x, y, z] = 1
# If Normal Tile
else
# If Autotile Drawn
if autotile_locations[x, y, z] == 1
# Redraw Normal Tile
draw_tile(x, y, p, id)
end
end
end
end
end
end
end
#--------------------------------------------------------------------------
# * Draw Tile
#--------------------------------------------------------------------------
def draw_tile(x, y, z, id)
# Figures Tile Rect
rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
# Calculates Tile Coordinates
x *= @tile_width
y *= @tile_height
# If Normal Tile
if @tile_width == 32 && @tile_height == 32
@layers[z].bitmap.blt(x, y, @tileset, rect)
# If Altered Dimensions
else
dest_rect = Rect.new(x, y, @tile_width, @tile_height)
@layers[z].bitmap.stretch_blt(dest_rect, @tileset, rect)
end
end
#--------------------------------------------------------------------------
# * Draw Auto-Tile
#--------------------------------------------------------------------------
def draw_autotile(x, y, z, tile_id)
# Gets Auto-Tile
autotile = @autotiles[tile_id / 48 - 1]
# Reconfigure Tile ID
tile_id %= 48
# Creates Bitmap
bitmap = Bitmap.new(32, 32)
# Collects Auto-Tile Tile Layout
tiles = Autotiles[tile_id / 8][tile_id % 8]
# Animated Tiles
frames = autotile.width / 96
# Configures Animation Offset
anim = (Graphics.frame_count / Animated_Autotiles_Frames) % frames * 96
# Draws Auto-Tile Rects
for i in 0...4
tile_position = tiles[i] - 1
src_rect = Rect.new(tile_position % 6 * 16 + anim, tile_position / 6 * 16, 16, 16)
bitmap.blt(i % 2 * 16, i / 2 * 16, autotile, src_rect)
end
# Calculates Tile Coordinates
x *= @tile_width
y *= @tile_height
# If Normal Tile
if @tile_width == 32 && @tile_height == 32
@layers[z].bitmap.blt(x, y, bitmap, Rect.new(0, 0, 32, 32))
# If Altered Dimensions
else
dest_rect = Rect.new(x, y, @tile_width, @tile_height)
@layers[z].bitmap.stretch_blt(dest_rect, bitmap, Rect.new(0, 0, 32, 32))
end
end
#--------------------------------------------------------------------------
# * Collect Bitmap
#--------------------------------------------------------------------------
def bitmap
# Creates New Blank Bitmap
bitmap = Bitmap.new(@layers[0].bitmap.width, @layers[0].bitmap.height)
# Passes Through All Layers
for layer in @layers
bitmap.blt(0, 0, layer.bitmap,
Rect.new(0, 0, bitmap.width, bitmap.height))
end
# Return Bitmap
return bitmap
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Demo