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.

Script to change the in-game resolution...

Heylo...

I was wondering if there was a script to change the resolution in-game so I can make a bigger tileset. The default is 640x480 but I need 1280x960, or double the size. I looked in the last 10 pages of script requests AND looked through the script request archives but couldn't find one.

If there ISN'T such a script could someone make it? And if there IS one, could you please point me to it? thanks a ton!
 
There is such a script, and you can find it if you look up bluescope's posts. Anyway, I've got a pet project I derived from that project's base, so here you go:

Code:
#==============================================================================
# ** Screen_Data
#------------------------------------------------------------------------------
#  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 = [20, 15, 640, 480, 2]
end

#==============================================================================
# ** Screen_Size
#------------------------------------------------------------------------------
#  This class handles the screen size. It is used within the Game_Map,
#  Game_Actor, Spriteset_Map, and Spriteset_Battle classes.
#==============================================================================
begin
class Screen_Size
  #--------------------------------------------------------------------------
  # * Change Screen Size
  #--------------------------------------------------------------------------
  def change_screen_size(width, height)
    window_width = width * (16 * Screen_Data::Screen_Data[4].to_s.to_f).to_i
    window_height = height * (16 * Screen_Data::Screen_Data[4].to_s.to_f).to_i
    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
    size = Screen_Data::Screen_Data[4].to_s.to_f
    self.resize_window(window_width, window_height)
  end
  #--------------------------------------------------------------------------
  # * Handle Window Size Changes
  #--------------------------------------------------------------------------
  def resize_window(width, height)
    game_title = "\0" * 256
    window_info = Win32API.new('kernel32', 'GetPrivateProfileString',
      %w(p p p p l p), 'l')
    window_info.call("Game", "Title", "", game_title, 256, ".\\Game.ini" )
    game_title.delete!("\0")
    system_metrics = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    screen_width = system_metrics.call(0)
    x_pos = (screen_width - (width + 6)) / 2
    screen_height = system_metrics.call(1)
    y_pos = (screen_height - (height + 32)) / 2
    find_window = Win32API.new('user32', 'FindWindow', %(p, p), 'i')
    window = find_window.call("RGSS Player", game_title)
    winpos = Win32API.new('user32', 'SetWindowPos', %(l, l, i, i, i, i, i), 'i')
    winpos.call(window, 0, x_pos, y_pos - 1, width + 6, height + 32, 0)
    winpos.call(window, 0, x_pos, y_pos, width + 6, height + 32, 0)
  end
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
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias glitchfinder_classic_screensize_initialize initialize
  def initialize
    glitchfinder_classic_screensize_initialize
    @size = Screen_Data::Screen_Data[4].to_s.to_f
    @width = Screen_Data::Screen_Data[0].to_s.to_i
    @height = Screen_Data::Screen_Data[1].to_s.to_i
  end
  #--------------------------------------------------------------------------
  # * Scroll Down
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    @display_y = [@display_y + distance, ((self.height - @height) *
      (64 * @size).to_i)].min
  end
  #--------------------------------------------------------------------------
  # * Scroll Right
  #     distance : scroll distance
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    @display_x = [@display_x + distance, ((self.width - @width) *
      (64 * @size).to_i)].min
  end
  #--------------------------------------------------------------------------
  # * Start Scroll
  #     direction : scroll direction
  #     distance  : scroll distance
  #     speed     : scroll speed
  #--------------------------------------------------------------------------
  def start_scroll(direction, distance, speed)
    @scroll_direction = direction
    @scroll_rest = distance * (64 * @size).to_i
    @scroll_speed = speed
  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
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias glitchfinder_classic_screensize_gchar_initialize initialize
  def initialize
    glitchfinder_classic_screensize_gchar_initialize
    @size = Screen_Data::Screen_Data[4].to_s.to_f
    width = Screen_Data::Screen_Data[2].to_s.to_i / 2
    height = Screen_Data::Screen_Data[3].to_s.to_i / 2
    @move_speed = 4 + (((@size / 2 ).to_i - 1) * 2)
    @center_x = (((width / 2).to_i * @size).to_i - (8 * @size).to_i) * 4
    @center_y = (((height / 2).to_i * @size).to_i - (8 * @size).to_i) * 4
  end
  #--------------------------------------------------------------------------
  # * Determine if Moving
  #--------------------------------------------------------------------------
  def moving?
    # If logical coordinates differ from real coordinates,
    # movement is occurring.
    return (@real_x != @x * (64 * @size).to_i or
      @real_y != @y * (64 * @size).to_i)
  end
  #--------------------------------------------------------------------------
  # * Move to Designated Position
  #     x : x-coordinate
  #     y : y-coordinate
  #--------------------------------------------------------------------------
  def moveto(x, y)
    @x = x % $game_map.width
    @y = y % $game_map.height
    @real_x = @x * (64 * @size).to_i
    @real_y = @y * (64 * @size).to_i
    @prelock_direction = 0
  end
  #--------------------------------------------------------------------------
  # * Get Screen X-Coordinates
  #--------------------------------------------------------------------------
  def screen_x
    # Get screen coordinates from real coordinates and map display position
    return (@real_x - $game_map.display_x + 3) / 4 + (16 * (@size / 2).to_i)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias glitchfinder_classic_screensize_update update
  def update
    glitchfinder_classic_screensize_update
    # If animation count exceeds maximum value
    # * Maximum value is move speed * 1 taken from basic value 18
    if @anime_count > 18 - @move_speed * ((@size / 2 ).to_i - 1)
      # If stop animation is OFF when stopping
      if not @step_anime and @stop_count > 0
        # Return to original pattern
        @pattern = @original_pattern
      # If stop animation is ON when moving
      else
        # Update pattern
        @pattern = (@pattern + 1) % 4
      end
      # Clear animation count
      @anime_count = 0
    end
    @zoom = (0.50 * @size.to_f)
  end
  #--------------------------------------------------------------------------
  # * Frame Update (jump)
  #--------------------------------------------------------------------------
  def update_jump
    # Reduce jump count by 1
    @jump_count -= 1
    # Calculate new coordinates
    @real_x = ((@real_x * @jump_count + @x * (128 * @size / 2).to_i) /
    (@jump_count + 1))
    @real_y = ((@real_y * @jump_count + @y * (128 * @size / 2).to_i) /
    (@jump_count + 1))
  end
  #--------------------------------------------------------------------------
  # * Update frame (move)
  #--------------------------------------------------------------------------
  def update_move
    # Convert map coordinates from map move speed into move distance
    distance = 2 ** @move_speed
    # If logical coordinates are further down than real coordinates
    if @y * ((128 * @size).to_i / 2) > @real_y
      # Move down
      @real_y = [@real_y + distance, @y * (64 * @size).to_i].min
    end
    # If logical coordinates are more to the left than real coordinates
    if @x * ((128 * @size).to_i / 2) < @real_x
      # Move left
      @real_x = [@real_x - distance, @x * (64 * @size).to_i].max
    end
    # If logical coordinates are more to the right than real coordinates
    if @x * ((128 * @size).to_i / 2) > @real_x
      # Move right
      @real_x = [@real_x + distance, @x * (64 * @size).to_i].min
    end
    # If logical coordinates are further up than real coordinates
    if @y * ((128 * @size).to_i / 2) < @real_y
      # Move up
      @real_y = [@real_y - distance, @y * (64 * @size).to_i].max
    end
    # If move animation is ON
    if @walk_anime
      # Increase animation count by 1.5
      @anime_count += 1.5
    # If move animation is OFF, and stop animation is ON
    elsif @step_anime
      # Increase animation count by 1
      @anime_count += 1
    end
  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_classic_screensize_initialize initialize
  def initialize
    glitchfinder_classic_screensize_initialize
    @size = Screen_Data::Screen_Data[4].to_s.to_f
    @width = Screen_Data::Screen_Data[0].to_s.to_i
    @height = Screen_Data::Screen_Data[1].to_s.to_i
  end
  #--------------------------------------------------------------------------
  # * Set Map Display Position to Center of Screen
  #--------------------------------------------------------------------------
  def center(x, y)
    max_x = ($game_map.width - @width) * (64 * @size).to_i
    max_y = ($game_map.height - @height) * (64 * @size).to_i
    $game_map.display_x = [0,
      [x * (64 * @size).to_i - @center_x, max_x].min].max
    $game_map.display_y = [0,
      [y * (64 * @size).to_i - @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

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character. It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport  : viewport
  #     character : character (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    @size = Screen_Data::Screen_Data[4].to_s.to_f
    @current_size = 2
    super(viewport)
    @character = character
    update
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
      @character_name != @character.character_name or
      @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = (8 * ((@size * 2) - 2)).to_i
        self.oy = (64 * (1 / @size)).to_i
      # If tile ID value is invalid
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
        self.ox = (@cw / 2) - ((8 * ((@size * 2) - 4) * -1).to_i)
        self.oy = @ch + ((16 * ((@size * 2) - 4) * -1).to_i)
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
    if @current_size != @size
      @zoom = (0.50 * @size.to_f)
      self.zoom_x = @zoom
      self.zoom_y = @zoom
      x = @character.screen_x
      x = x * @zoom
      y = @character.screen_y
      y = y * @zoom
      self.x = x
      self.y = y
      @current_size = @size
    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
  #--------------------------------------------------------------------------
  alias glitchfinder_classic_screensize_initialize initialize
  def initialize
    glitchfinder_classic_screensize_initialize
    width = size = Screen_Data::Screen_Data[2].to_s.to_f
    height = size = Screen_Data::Screen_Data[3].to_s.to_f
    size = Screen_Data::Screen_Data[4].to_s.to_f
    @viewport1 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
    @viewport2 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
    @viewport3 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
    @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

#==============================================================================
# ** 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
  window = Screen_Size.new
  window = window.change_screen_size(width, height)
end

Anyway, some warnings: First, this will not work properly on all computers, as it uses Win32API. (Thus, it may not work at all on a Mac or Linux, and doesn't even function the same on every version of Windows) This is the only way to change the screen size without compiling your own DLL, though. Next, you will need a custom tilemap to display all of the tiles outside of default viewport size. Third, unless you want to change how things move, do not edit the 2 in the constant at the top of the script. To change the screen size, change the first two values to the number of tiles in each direction that the program will display. (In that constant at the top) Finally, you will need to edit every window in the game, as this script will not do that for you. So, you'll need a CMS, some edits to the DBS, and edits to several other windows, like the message window. Anyway, I hope this works for you.
 
THANK YOU SO MUCH GLITCH!!!!

I already have a tileset I'm working on that uses a base 64x64, basically 4 tiles at a time so if I double the resolution it will still be about the same size as a regular rmxp game  =)
 
Ricoman":13m77y3h said:
THANK YOU SO MUCH GLITCH!!!!

I already have a tileset I'm working on that uses a base 64x64, basically 4 tiles at a time so if I double the resolution it will still be about the same size as a regular rmxp game  =)

Actually, it is rather difficult to get the game to use 64x64 tiles w/o hacking the editor. You might want to talk to SephirothSpawn about a possible modification of his tilemap to make that work, but I'm not sure many people would be able to do that kind of thing. (Unless you already have a method to do that. If you do, just ignore me...) Anyway, I hope you get some use out of this script.
 
Well, what I mean is that it's still the 32x32 tiles, but I just make the graphics 64x64, so it's technically still 32x32 for the game grid but my graphics are double-size, if that makes sense.

Here's my latest map made entirely with my custom tileset: WARNING EXTREMELY LARGE IMAGE, 3200X3200
http://i181.photobucket.com/albums/x259/Ricoman2000/re-TEST.jpg[/img]
 
Glitchfinder":3e07xy3t said:
Ricoman":3e07xy3t said:
THANK YOU SO MUCH GLITCH!!!!

I already have a tileset I'm working on that uses a base 64x64, basically 4 tiles at a time so if I double the resolution it will still be about the same size as a regular rmxp game  =)

Actually, it is rather difficult to get the game to use 64x64 tiles w/o hacking the editor. You might want to talk to SephirothSpawn about a possible modification of his tilemap to make that work, but I'm not sure many people would be able to do that kind of thing. (Unless you already have a method to do that. If you do, just ignore me...) Anyway, I hope you get some use out of this script.
Hacking the editor is illegal...
 
killerzkings":3dus6kvy said:
Hacking the editor is illegal...

I realize that. I just didn't mention it because only a couple of people on the forum here have that kind of capabilility (vgvgf is the only one who comes to mind) and so I thought it was poinltless. Also, @Ricoman: That looks pretty cool! I personally like what you're doing, and I think it has a great deal of potential.
 
Thanks! I've actually got quite a bit more done since then:

http://i181.photobucket.com/albums/x259/Ricoman2000/MAP003.png[/img]

there are few things to fix yet, but it's all in progress lol
 
Ricoman":17qswski said:
Thanks! I've actually got quite a bit more done since then:

http://i181.photobucket.com/albums/x259/Ricoman2000/MAP003.png[/img]

there are few things to fix yet, but it's all in progress lol

The tiles are still pretty cool. Though, I just realized that unless you want to just see the characters' hair, you've got an odd perspective.
 

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