Kod:
#===============================================================================
# * Resize RMVX by Leon_Westbrooke - v. 1.1
#-------------------------------------------------------------------------------
# This script allows you to resize the game window for your RMVX game.
#
# Instructions: Fill out the module's values for WIDTH and HEIGHT.
#
# Notes:
# All other menus will have to be rewritten to fill the screen completely.
# You can do this, or search for any scripts that use a larger/smaller
# display size. I will be writing some scripts for 640x480 display; mainly
# because I prefer that size.
#
# The max size is 640x480.
#
# Overwritten Methods:
# Game_Player
# center(x, y)
# Game_Map
# setup_scroll
# scroll_down(distance)
# scroll_right(distance)
#===============================================================================
#-------------------------------------------------------------------------------
# * RESIZE module
#-------------------------------------------------------------------------------
module RESIZE
#-----------------------------------------------------------------------------
# Sets width of the window.
#-----------------------------------------------------------------------------
WIDTH = 640
#-----------------------------------------------------------------------------
# Sets height of the window.
#-----------------------------------------------------------------------------
HEIGHT = 480
end
#-------------------------------------------------------------------------------
# END RESIZE module
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# * Game_Player class
#-------------------------------------------------------------------------------
class Game_Player
#-----------------------------------------------------------------------------
# CENTER_X and CENTER_Y are recalculated with a variable instead of integer.
#-----------------------------------------------------------------------------
CENTER_X = (RESIZE::WIDTH / 2 - 16) * 8
CENTER_Y = (RESIZE::HEIGHT / 2 - 16) * 8
#--------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def center(x, y)
display_x = x * 256 - CENTER_X # Calculate coordinates
unless $game_map.loop_horizontal? # No loop horizontally?
max_x = ($game_map.width - (RESIZE::WIDTH / 32)) * 256 # Calculate max value
display_x = [0, [display_x, max_x].min].max # Adjust coordinates
end
display_y = y * 256 - CENTER_Y # Calculate coordinates
unless $game_map.loop_vertical? # No loop vertically?
max_y = ($game_map.height - (RESIZE::HEIGHT / 32)) * 256 # Calculate max value
display_y = [0, [display_y, max_y].min].max # Adjust coordinates
end
$game_map.set_display_pos(display_x, display_y) # Change map location
end
end
#-------------------------------------------------------------------------------
# END Game_Player class
#-------------------------------------------------------------------------------
class Game_Map
def setup_scroll
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
@margin_x = (width - (RESIZE::WIDTH / 32)) * 256 / 2 # Screen non-display width /2
@margin_y = (height - (RESIZE::HEIGHT / 32)) * 256 / 2 # Screen non-display height /2
end
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
if loop_vertical?
@display_y += distance
@display_y %= @map.height * 256
@parallax_y += distance
else
last_y = @display_y
@display_y = [@display_y + distance,
(height - (RESIZE::HEIGHT / 32)) * 256].min
@parallax_y += @display_y - last_y
end
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
if loop_horizontal?
@display_x += distance
@display_x %= @map.width * 256
@parallax_x += distance
else
last_x = @display_x
@display_x = [@display_x + distance,
(width - (RESIZE::WIDTH / 32)) * 256].min
@parallax_x += @display_x - last_x
end
end
end
#-------------------------------------------------------------------------------
# Resizes game.
#-------------------------------------------------------------------------------
Graphics.resize_screen(RESIZE::WIDTH, RESIZE::HEIGHT)
#-------------------------------------------------------------------------------
# END Resize
#-------------------------------------------------------------------------------