Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Smaller Resolution Script?

Ok, so RMXP's default resolution is just a bit too big for me. I'm using small sprites so there's just way too much extra space on the screen at the moment.
So what I need is a script that can change the resolution to a smaller size(probably just a tad bigger than VX's).
I've searched around and found Selwyn's Custom Res Script but it doesn't work for me if I try to make it smaller, just bigger. I also found Bluescope's Script but that changes the tile size as well, I just need a smaller screen with nothing else changed. None of the fancy changing tile sizes, resizing tilesets and things like that.
If anyone knows of such a script that'd be absolutely amazing(or if you wanna make a completely new one that'd be even more amazing, though I'm not expecting this since I assume it'd be really complicated and take forever, and I wouldn't expect someone to put that much time and effort into a free request, but hey if you want to ^_^) 

^_^
 
Surprisingly, I have most of what you need on my laptop at home. Gimme a while, and when I get home, I can find it, finish it, and post it. Also, what was the screen size you were looking for? (In tiles, not pixels)  Unfortunately, I will not modify the default menus to fit. That takes quite a bit of time and effort, and must be redone for every seperate size. (I will modify the title screen, however)
 

ikos

Member

Code:
#==============================================================================
# ** Resolution Changer VX
#------------------------------------------------------------------------------
# by Syvkal
# Version 1.0
# 06-27-08
#==============================================================================
#
#  - INTRODUCTION -
#
#  This system allows you to resize the Game screen without stretching the
#  graphics. It enables you to be able to fit more onto one screen
#
#------------------------------------------------------------------------------
#
#  - USAGE -
#
#  Simply use the one line:
#
#      Graphics.resize_screen(480,320)
#
#  Place this in main just below 'begin'
#
#------------------------------------------------------------------------------
#
#  - PROBLEMS -
#
#  Certain problems may occur while using this script
#  These include:
#    -  Windows not properly sized
#    -  Windows not in the proper position
#    -  Images such as the Title Graphic not fitting
#
#  NONE OF THESE PROBLEMS ARE ERRORS
#   -------------------------------
#
#  Please do not report any of these problems, the resolution script will
#  the screen size, it's up to you to make the scripts fit it
#
#  However the script is quite new and only took me about 10 minutes, so if
#  there are any errors please do report them  
#
#------------------------------------------------------------------------------
#
#  - IMPORTANT -
#
#  When resizing the window try to make the width and height a multiple of 32
#  This will reduce the amount of errors
#
#  Also due to the Built in function, the current max screen size is 640 x 480
#  In later versions this problem may be able to be over come, but I'm not sure
#
#==============================================================================

#==============================================================================
# ** Sprite_Base
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # * Start Animation
  #--------------------------------------------------------------------------
  def start_animation(animation, mirror = false)
    dispose_animation
    @animation = animation
    return if @animation == nil
    @animation_mirror = mirror
    @animation_duration = @animation.frame_max * 4 + 1
    load_animation_bitmap
    @animation_sprites = []
    if @animation.position != 3 or not @@animations.include?(animation)
      if @use_sprite
        for i in 0..15
          sprite = ::Sprite.new(viewport)
          sprite.visible = false
          @animation_sprites.push(sprite)
        end
        unless @@animations.include?(animation)
          @@animations.push(animation)
        end
      end
    end
    if @animation.position == 3
      if viewport == nil
        @animation_ox = Graphics.width / 2
        @animation_oy = Graphics.height / 2
      else
        @animation_ox = viewport.rect.width / 2
        @animation_oy = viewport.rect.height / 2
      end
    else
      @animation_ox = x - ox + width / 2
      @animation_oy = y - oy + height / 2
      if @animation.position == 0
        @animation_oy -= height / 2
      elsif @animation.position == 2
        @animation_oy += height / 2
      end
    end
  end
end

#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : viewport
  #--------------------------------------------------------------------------
  def initialize(viewport)
    super(viewport)
    self.bitmap = Bitmap.new(88, 48)
    self.bitmap.font.name = "Arial"
    self.bitmap.font.size = 32
    self.x = Graphics.width - self.bitmap.width
    self.y = 0
    self.z = 200
    update
  end
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Create Viewport
  #--------------------------------------------------------------------------
  def create_viewports
    @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2.z = 50
    @viewport3.z = 100
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Create Viewport
  #--------------------------------------------------------------------------
  def create_viewports
    @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2.z = 50
    @viewport3.z = 100
  end
  #--------------------------------------------------------------------------
  # * Create Battleback Sprite
  #--------------------------------------------------------------------------
  def create_battleback
    source = $game_temp.background_bitmap
    bitmap = Bitmap.new(Graphics.width + 96, Graphics.height + 64)
    bitmap.stretch_blt(bitmap.rect, source, source.rect)
    bitmap.radial_blur(90, 12)
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = bitmap
    @battleback_sprite.ox = 320
    @battleback_sprite.oy = 240
    @battleback_sprite.x = 272
    @battleback_sprite.y = 176
    @battleback_sprite.wave_amp = 8
    @battleback_sprite.wave_length = 240
    @battleback_sprite.wave_speed = 120
  end
  #--------------------------------------------------------------------------
  # * Create Battlefloor Sprite
  #--------------------------------------------------------------------------
  def create_battlefloor
    @battlefloor_sprite = Sprite.new(@viewport1)
    @battlefloor_sprite.bitmap = Cache.system("BattleFloor")
    @battlefloor_sprite.x = 0
    @battlefloor_sprite.y = 192
    @battlefloor_sprite.z = 1
    @battlefloor_sprite.opacity = 128
  end
end


#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Scroll Setup
  #--------------------------------------------------------------------------
  def setup_scroll
    @scroll_direction = 2
    @scroll_rest = 0
    @scroll_speed = 4
    @margin_x = (width - (Graphics.width / 32)) * 256 / 2
    @margin_y = (height - (Graphics.height / 32)) * 256 / 2
  end
  #--------------------------------------------------------------------------
  # * Calculate X coordinate for parallax display 
  #     bitmap : Parallax bitmap
  #--------------------------------------------------------------------------
  def calc_parallax_x(bitmap)
    if bitmap == nil
      return 0
    elsif @parallax_loop_x
      return @parallax_x / 16
    elsif loop_horizontal?
      return 0
    else
      w1 = bitmap.width - Graphics.width
      w2 = @map.width * 32 - Graphics.width
      if w1 <= 0 or w2 <= 0
        return 0
      else
        return @parallax_x * w1 / w2 / 8
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Y coordinate for parallax display 
  #     bitmap : Parallax bitmap
  #--------------------------------------------------------------------------
  def calc_parallax_y(bitmap)
    if bitmap == nil
      return 0
    elsif @parallax_loop_y
      return @parallax_y / 16
    elsif loop_vertical?
      return 0
    else
      h1 = bitmap.height - Graphics.height
      h2 = @map.height * 32 - Graphics.height
      if h1 <= 0 or h2 <= 0
        return 0
      else
        return @parallax_y * h1 / h2 / 8
      end
    end
  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 - (Graphics.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 - (Graphics.width / 32)) * 256].min
      @parallax_x += @display_x - last_x
    end
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Set Map Display Position to Center of Screen
  #     x : x-coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------
  def center(x, y)
    center_x = (Graphics.width / 2 - 16) * 8
    center_y = (Graphics.width / 2 - 16) * 8
    display_x = x * 256 - center_x                   # Calculate coordinates
    unless $game_map.loop_horizontal?                 # No loop horizontally?
      max_x = ($game_map.width - (Graphics.width / 32)) * 256
      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 - (Graphics.height / 32)) * 256
      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
  #--------------------------------------------------------------------------
  # * Update Scroll
  #--------------------------------------------------------------------------
  def update_scroll(last_real_x, last_real_y)
    center_x = (Graphics.width / 2 - 16) * 8
    center_y = (Graphics.width / 2 - 16) * 8
    ax1 = $game_map.adjust_x(last_real_x)
    ay1 = $game_map.adjust_y(last_real_y)
    ax2 = $game_map.adjust_x(@real_x)
    ay2 = $game_map.adjust_y(@real_y)
    if ay2 > ay1 and ay2 > center_y
      $game_map.scroll_down(ay2 - ay1)
    end
    if ax2 < ax1 and ax2 < center_x
      $game_map.scroll_left(ax1 - ax2)
    end
    if ax2 > ax1 and ax2 > center_x
      $game_map.scroll_right(ax2 - ax1)
    end
    if ay2 < ay1 and ay2 < center_y
      $game_map.scroll_up(ay1 - ay2)
    end
  end
end
 
ikos":1mq8zldi said:
Code:
#==============================================================================
# ** Resolution Changer VX
#------------------------------------------------------------------------------
# by Syvkal
# Version 1.0
# 06-27-08
#==============================================================================
#
#  - INTRODUCTION -
#
#  This system allows you to resize the Game screen without stretching the
#  graphics. It enables you to be able to fit more onto one screen
#
#------------------------------------------------------------------------------
#
#  - USAGE -
#
#  Simply use the one line:
#
#      Graphics.resize_screen(480,320)
#
#  Place this in main just below 'begin'
#
#------------------------------------------------------------------------------
#
#  - PROBLEMS -
#
#  Certain problems may occur while using this script
#  These include:
#    -  Windows not properly sized
#    -  Windows not in the proper position
#    -  Images such as the Title Graphic not fitting
#
#  NONE OF THESE PROBLEMS ARE ERRORS
#   -------------------------------
#
#  Please do not report any of these problems, the resolution script will
#  the screen size, it's up to you to make the scripts fit it
#
#  However the script is quite new and only took me about 10 minutes, so if
#  there are any errors please do report them  
#
#------------------------------------------------------------------------------
#
#  - IMPORTANT -
#
#  When resizing the window try to make the width and height a multiple of 32
#  This will reduce the amount of errors
#
#  Also due to the Built in function, the current max screen size is 640 x 480
#  In later versions this problem may be able to be over come, but I'm not sure
#
#==============================================================================

#==============================================================================
# ** Sprite_Base
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # * Start Animation
  #--------------------------------------------------------------------------
  def start_animation(animation, mirror = false)
    dispose_animation
    @animation = animation
    return if @animation == nil
    @animation_mirror = mirror
    @animation_duration = @animation.frame_max * 4 + 1
    load_animation_bitmap
    @animation_sprites = []
    if @animation.position != 3 or not @@animations.include?(animation)
      if @use_sprite
        for i in 0..15
          sprite = ::Sprite.new(viewport)
          sprite.visible = false
          @animation_sprites.push(sprite)
        end
        unless @@animations.include?(animation)
          @@animations.push(animation)
        end
      end
    end
    if @animation.position == 3
      if viewport == nil
        @animation_ox = Graphics.width / 2
        @animation_oy = Graphics.height / 2
      else
        @animation_ox = viewport.rect.width / 2
        @animation_oy = viewport.rect.height / 2
      end
    else
      @animation_ox = x - ox + width / 2
      @animation_oy = y - oy + height / 2
      if @animation.position == 0
        @animation_oy -= height / 2
      elsif @animation.position == 2
        @animation_oy += height / 2
      end
    end
  end
end

#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : viewport
  #--------------------------------------------------------------------------
  def initialize(viewport)
    super(viewport)
    self.bitmap = Bitmap.new(88, 48)
    self.bitmap.font.name = "Arial"
    self.bitmap.font.size = 32
    self.x = Graphics.width - self.bitmap.width
    self.y = 0
    self.z = 200
    update
  end
end

#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Create Viewport
  #--------------------------------------------------------------------------
  def create_viewports
    @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2.z = 50
    @viewport3.z = 100
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Create Viewport
  #--------------------------------------------------------------------------
  def create_viewports
    @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @viewport2.z = 50
    @viewport3.z = 100
  end
  #--------------------------------------------------------------------------
  # * Create Battleback Sprite
  #--------------------------------------------------------------------------
  def create_battleback
    source = $game_temp.background_bitmap
    bitmap = Bitmap.new(Graphics.width + 96, Graphics.height + 64)
    bitmap.stretch_blt(bitmap.rect, source, source.rect)
    bitmap.radial_blur(90, 12)
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = bitmap
    @battleback_sprite.ox = 320
    @battleback_sprite.oy = 240
    @battleback_sprite.x = 272
    @battleback_sprite.y = 176
    @battleback_sprite.wave_amp = 8
    @battleback_sprite.wave_length = 240
    @battleback_sprite.wave_speed = 120
  end
  #--------------------------------------------------------------------------
  # * Create Battlefloor Sprite
  #--------------------------------------------------------------------------
  def create_battlefloor
    @battlefloor_sprite = Sprite.new(@viewport1)
    @battlefloor_sprite.bitmap = Cache.system("BattleFloor")
    @battlefloor_sprite.x = 0
    @battlefloor_sprite.y = 192
    @battlefloor_sprite.z = 1
    @battlefloor_sprite.opacity = 128
  end
end


#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Scroll Setup
  #--------------------------------------------------------------------------
  def setup_scroll
    @scroll_direction = 2
    @scroll_rest = 0
    @scroll_speed = 4
    @margin_x = (width - (Graphics.width / 32)) * 256 / 2
    @margin_y = (height - (Graphics.height / 32)) * 256 / 2
  end
  #--------------------------------------------------------------------------
  # * Calculate X coordinate for parallax display 
  #     bitmap : Parallax bitmap
  #--------------------------------------------------------------------------
  def calc_parallax_x(bitmap)
    if bitmap == nil
      return 0
    elsif @parallax_loop_x
      return @parallax_x / 16
    elsif loop_horizontal?
      return 0
    else
      w1 = bitmap.width - Graphics.width
      w2 = @map.width * 32 - Graphics.width
      if w1 <= 0 or w2 <= 0
        return 0
      else
        return @parallax_x * w1 / w2 / 8
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Y coordinate for parallax display 
  #     bitmap : Parallax bitmap
  #--------------------------------------------------------------------------
  def calc_parallax_y(bitmap)
    if bitmap == nil
      return 0
    elsif @parallax_loop_y
      return @parallax_y / 16
    elsif loop_vertical?
      return 0
    else
      h1 = bitmap.height - Graphics.height
      h2 = @map.height * 32 - Graphics.height
      if h1 <= 0 or h2 <= 0
        return 0
      else
        return @parallax_y * h1 / h2 / 8
      end
    end
  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 - (Graphics.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 - (Graphics.width / 32)) * 256].min
      @parallax_x += @display_x - last_x
    end
  end
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  Edited to handle the resized screen size
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Set Map Display Position to Center of Screen
  #     x : x-coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------
  def center(x, y)
    center_x = (Graphics.width / 2 - 16) * 8
    center_y = (Graphics.width / 2 - 16) * 8
    display_x = x * 256 - center_x                   # Calculate coordinates
    unless $game_map.loop_horizontal?                 # No loop horizontally?
      max_x = ($game_map.width - (Graphics.width / 32)) * 256
      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 - (Graphics.height / 32)) * 256
      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
  #--------------------------------------------------------------------------
  # * Update Scroll
  #--------------------------------------------------------------------------
  def update_scroll(last_real_x, last_real_y)
    center_x = (Graphics.width / 2 - 16) * 8
    center_y = (Graphics.width / 2 - 16) * 8
    ax1 = $game_map.adjust_x(last_real_x)
    ay1 = $game_map.adjust_y(last_real_y)
    ax2 = $game_map.adjust_x(@real_x)
    ay2 = $game_map.adjust_y(@real_y)
    if ay2 > ay1 and ay2 > center_y
      $game_map.scroll_down(ay2 - ay1)
    end
    if ax2 < ax1 and ax2 < center_x
      $game_map.scroll_left(ax1 - ax2)
    end
    if ax2 > ax1 and ax2 > center_x
      $game_map.scroll_right(ax2 - ax1)
    end
    if ay2 < ay1 and ay2 < center_y
      $game_map.scroll_up(ay1 - ay2)
    end
  end
end

Actually, this is for XP. I've almost completely smoothed out the problems with what I was working on, so I should be able to post it soon.
 
Ok, I just finished. This one took a while, because for some reson I kept getting an undocumented catchall error that told me nothing. Anyway, I finally figured it out, and I told it to fix the title screen. Oh, and I also decided to add the header with instructions that I add to every script I release. It is currently set to the screen size that you wanted, though it is easy to change. Also, the hardest part of this script, once I got it working, was centering the playter on the map. (I work with this kind of script a lot on my free time, so I already knew that would be a problem. Oh well, since I'm probably boring you, I'll just get on to the script.

Code:
#==============================================================================
# ** Glitchfinder's RMXP Screen Size Editor (Version 1.00)
#------------------------------------------------------------------------------
#  This script is meant to allow the programmer to change the screen size of
#  the RPG Maker XP window.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Instructions
#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
#  Place this script above Main, and below the default scripts. (I
#  realize this is obvious to most, but some people don't get it.)
#
#  To change the default screen size, simply edit the Screen_Data module, which
#  uses the following format:
#  [width (in tiles), height (in tiles), width, height]
#
#  To edit the size of the screen in game, simply use the following function:
#  Screen_Size.change_screen_size(width, height)
#  The width and height must be the number of tiles that you want the screen to
#  display in each direction.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Glitchfinder's Advice
#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
#  This script is meant for people with a medium to high level of scripting
#  knowledge and ability. If you are unsure of your abilities, or don't know
#  how to script, then it would be a good idea to avoid this script.
#
#  If you are editing the default screen size in the Screen_Data module, the
#  second width and height should be the same as the first width and height
#  multiplied by 32, so that the player will display properly on the map.
#  (Although it doesn't really matter, seeing as they are fixed automatically
#  if they aren't)
#
#  If you make the screen size larger than the default, you must make sure that
#  all of your maps are at least that large, or you will get a fatal error.
#
#  If you use this script, you must be prepared to create your own custom
#  menus, titles, gameovers, etc. to fit the new screen size.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# * Usage
#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
#  This script may be used in any commercial or non-commercial
#  project.
#
#  Please credit Glitchfinder if you use this script.
#==============================================================================
#==============================================================================
# ** Screen_Size
#------------------------------------------------------------------------------
#  This module handles the information regarding screen size. It is used within
#  the Screen_Size, Game_Map, Game_Player, Spriteset_Map, and Spriteset_Battle
#  classes.
#==============================================================================

module Screen_Data
    Screen_Data = [15, 10, 480, 320]
end

#==============================================================================
# ** Screen_Size
#------------------------------------------------------------------------------
#  This class handles the screen size. It is used within the Game_Map,
#  Game_Actor, Spriteset_Map, and Spriteset_Battle classes.
#==============================================================================

class Screen_Size
  #--------------------------------------------------------------------------
  # * Change Screen Size
  #--------------------------------------------------------------------------
  def change_screen_size(width, height)
    window_width = width * 32
    window_height = height * 32
    Screen_Data::Screen_Data[0] = width
    Screen_Data::Screen_Data[1] = height
    Screen_Data::Screen_Data[2] = window_width
    Screen_Data::Screen_Data[3] = window_height
    self.resize_window((width * 32), (height * 32))
  end
  #--------------------------------------------------------------------------
  # * Handle Window Size Changes
  #--------------------------------------------------------------------------
  def resize_window(width, height)
    getSystemMetrics = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    moveWindow = Win32API.new('user32','MoveWindow',
      ['l','i','i','i','i','l'],'l')
    findWindowEx = Win32API.new('user32','FindWindowEx',['l','l','p','p'],'i')
    window = findWindowEx.call(0,0,"RGSS Player",0)
    screenwidth = getSystemMetrics.call(0)
    screenheight = getSystemMetrics.call(1)
    windowwidth = width + 6
    windowheight = height + 32
    moveWindow.call(window,(screenwidth - windowwidth) / 2,
      (screenheight - windowheight) / 2,windowwidth,windowheight,1) 
  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
  #--------------------------------------------------------------------------
  # * Scroll Down
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    @display_y = [@display_y + distance,
      (self.height - Screen_Data::Screen_Data[1].to_s.to_i) * 128].min
  end
  #--------------------------------------------------------------------------
  # * Scroll Right
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    screen = Screen_Size.new
    @display_x = [@display_x + distance,
      (self.width - Screen_Data::Screen_Data[0].to_s.to_i) * 128].min
  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
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias glitchfinder_screen_resizer_initialize initialize
  def initialize
    width = (Screen_Data::Screen_Data[2].to_s.to_i / 2)
    height = (Screen_Data::Screen_Data[3].to_s.to_i / 2)
    @center_x = (width - 16) * 4
    @center_y = (height - 16) * 4
    glitchfinder_screen_resizer_initialize
  end
  #--------------------------------------------------------------------------
  # * Set Map Display Position to Center of Screen
  #--------------------------------------------------------------------------
  def center(x, y)
    max_x = ($game_map.width - Screen_Data::Screen_Data[1].to_s.to_i) * 128
    max_y = ($game_map.height - Screen_Data::Screen_Data[2].to_s.to_i) * 128
    $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
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Remember whether or not moving in local variables
    last_moving = moving?
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # Move player in the direction the directional button is being pressed
      case Input.dir4
      when 2
        move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        move_up
      end
    end
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # If character moves down and is positioned lower than the center
    # of the screen
    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
    # 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
      # Scroll map left
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # If character moves right and is positioned 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
    # 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
    # If not moving
    unless moving?
      # If player was moving last time
      if last_moving
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])
        # If event which started does not exist
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Same position and front event determinant
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    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
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    width = Screen_Data::Screen_Data[2].to_s.to_i
    height = Screen_Data::Screen_Data[3].to_s.to_i
    # Make viewports
    @viewport1 = Viewport.new(0, 0, width, height)
    @viewport2 = Viewport.new(0, 0, width, height)
    @viewport3 = Viewport.new(0, 0, width, height)
    @viewport2.z = 200
    @viewport3.z = 5000
    # Make tilemap
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names[i]
      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    # Make panorama plane
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    # Make fog plane
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    # Make character sprites
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    width = Screen_Data::Screen_Data[2].to_s.to_i
    height = Screen_Data::Screen_Data[3].to_s.to_i
    # Make viewports
    @viewport1 = Viewport.new(0, 0, width, ((height * 2) / 3).to_i)
    @viewport2 = Viewport.new(0, 0, width, height)
    @viewport3 = Viewport.new(0, 0, width, height)
    @viewport4 = Viewport.new(0, 0, width, height)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    # Make battleback sprite
    @battleback_sprite = Sprite.new(@viewport1)
    # Make enemy sprites
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # Make actor sprites
    @actor_sprites = []
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    # Make weather
    @weather = RPG::Weather.new(@viewport1)
    # Make picture sprites
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
        $game_screen.pictures[i]))
    end
    # Make timer sprite
    @timer_sprite = Sprite_Timer.new
    # Frame update
    update
  end
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # If battle test
    if $BTEST
      battle_test
      return
    end
    # Load database
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
    # Make system object
    $game_system = Game_System.new
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    # Make command window
    s1 = "New Game"
    s2 = "Continue"
    s3 = "Shutdown"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.back_opacity = 160
    @command_window.x = ((Screen_Data::Screen_Data[2].to_s.to_i / 2) -
                        (@command_window.width / 2))
    num = (((Screen_Data::Screen_Data[3].to_s.to_i - 128) * 9) / 11).to_i
    @command_window.y = num
    # Continue enabled determinant
    # Check if at least one save file exists
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If continue is enabled, move cursor to "Continue"
    # If disabled, display "Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    # Play title BGM
    $game_system.bgm_play($data_system.title_bgm)
    # Stop playing ME and BGS
    Audio.me_stop
    Audio.bgs_stop
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of command window
    @command_window.dispose
    # Dispose of title graphic
    @sprite.bitmap.dispose
    @sprite.dispose
  end
end

#==============================================================================
# ** Screen_Resizer
#------------------------------------------------------------------------------
#  This will begin the screen size change.
#==============================================================================
begin
  width = Screen_Data::Screen_Data[0].to_s.to_i
  height = Screen_Data::Screen_Data[1].to_s.to_i
  screen = Screen_Size.new
  screen.change_screen_size(width, height)
end
 
The Panda":27sp6vsx said:
That's awesome Glitch it's perfect! ^_^
I'll give you credits and such and if you ever need any sprites done throw a PM my way, I'll be more than happy to do em for you ^_^

You're welcome. I've been messing around with this kind of thing for a while. I just found it sort of odd that you are using a GBA sized screen. Anyway, I hope you like it!. (As a side note, if you make the screen larger than the default, you have to make the maps at least that size, or you get a fatal error)

EDIT: I just updated the header, because I realized that I made some mistakes when I copied it from one of my other scripts. Credit to SephirothSpawn is not required, like it is in the pre-beta version of the script this was based on, and I also added another disclaimer.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top