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.

[Resolved] Resolution [RMXP]

I've searched and found tons of scripts that can change resolution and order windows and stuff. But I know there is a way (maybe one line or so) to change the resolution easily, and I remember to have done it before. Of course the menus and messages look weird but I'll fix them manually myself. I just want to now, how can I change the resolution to, say, 480x320 without pages of scripts that do complicated things for me?

I found some post that was putting "Graphics.resize(480, 320)" above main, but it does not work for me, because "resize" doesn't mean anything in a new project. Am I missing something?
 
No, you aren't missing anything, if you plan on using RMVX. The one-line method you mentioned only works there. I have posted some of those scripts in the past, if you wanted to search "resolution" based on my posts.
 
Okay, thanks. That means that, if I'm using RMXP, there's no easy way to do this? (Like I said, it does not need to do complicated stuff for me.) Do I have to use Selwyn's ultra-amazing script?
 
Shiny Umbreon":3dnl54dc said:
Oh, okay. I don't want to get into complicated stuff because I lack scripting knowledge, so I'll figure out what to do. Thanks for the information, anyway.
As I said, do a quick search under my posts. Here is my most recont post on that topic that includes a script:

Glitchfinder":3dnl54dc said:
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.
 
Shiny Umbreon":281e9wv2 said:
Sorry, I didn't found that one. Thanks then, I'll try that one. Seems really useful.

EDIT: I tried it and it's perfect. By the way, who should I credit for this?

Although the idea is derived from Selwyn's demo, I actually scripted it myself, so Glitchfinder should be the only credit that you could do. Thank's for asking.
 

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