Change game sizescreen but keep 640x480 (stretched)

Hello guys!
So I made my game entirelly 640x480. But I would like to give more options to the player because 640x480 nowadays could be very small on bigger screens. And some players dont want to play fullscreen (alt + enter).

So I would like to ask for a script to add an option to the player to choose the screen size of the game.

I would like a new button option to be added on the MENU and the title screen called "Screen Size"

This button could have like 4 options.

Default (640x480)

1280 x 960

1400 x 1050

Fullscreen (Alt + enter)

*Please note that the game, pictures, and sprites will remain at the default size. It should just stretch just like alt + enter does.

*I have look some scripts through the internet but I just found scripts to resize the entire game. I just want to stretch the screen.


Please let me know if its something possible to do!
Looking forward to some information about that.

Cheers!
This has been quite the journey...
I didn't manage to solve a small bug, which is a black border showing up on title screen, but this is only happening on the title screen, ingame has no black borders.
I added other resolutions, but you can easily adjust the resolutions you want in the SIZES list


Spoiler: Screen Resizing Material
Ruby:
# Screen Size Options Script
# Add this script below Materials and above Main

module Screen_Size
  BASE_WIDTH = 544
  BASE_HEIGHT = 416
  COMMAND_NAME = "Screen size"

  SIZES = [
    ["Default", BASE_WIDTH, BASE_HEIGHT],
    ["640x480", 640, 480],
    ["900x600", 900, 600],
    ["1280x960", 1280, 960],
    ["1400x1050", 1400, 1050],
    ["Fullscreen", -1, -1]
  ]

  def self.change_size(index)
    width, height = SIZES[index][1], SIZES[index][2]
    if width == -1 && height == -1
      toggle_fullscreen
    else
      Graphics.resize_screen(width, height)
      resize_window(width, height)
    end
  end

  def self.toggle_fullscreen
    if defined?(Win32API)
      user32 = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
      sm_cxscreen = user32.call(0)
      sm_cyscreen = user32.call(1)
      resize_window(sm_cxscreen, sm_cyscreen)
    end
  end

  def self.resize_window(width, height)
    hwnd = Win32API.new('user32', 'GetForegroundWindow', '', 'L').call
    set_window_pos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    # Get the screen size to center the window
    user32 = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    screen_width = user32.call(0)
    screen_height = user32.call(1)
    x = (screen_width - width) / 2
    y = (screen_height - height) / 2
    set_window_pos.call(hwnd, 0, x, y, width, height, 0x0040)
  end
end

class Window_ScreenSize < Window_Command
  def initialize
    super(0, 0)
    center_window
    select(0)
  end

  def window_width
    return 200
  end

  def make_command_list
    Screen_Size::SIZES.each do |size|
      add_command(size[0], :screen_size)
    end
  end

  def center_window
    self.x = (Graphics.width - window_width) / 2
    self.y = (Graphics.height - window_height) / 2
  end
end

class Scene_ScreenSize < Scene_MenuBase
  def start
    super
    create_command_window
  end

  def create_command_window
    @command_window = Window_ScreenSize.new
    @command_window.set_handler(:screen_size, method(:command_size))
    @command_window.set_handler(:cancel, method(:return_scene))
    @command_window.set_handler(:ok, method(:command_size))
    @command_window.open
  end

  def command_size
    Screen_Size.change_size(@command_window.index)
    return_scene
  end
end

class Scene_Title < Scene_Base
  alias original_create_command_window create_command_window

  def create_command_window
    original_create_command_window
    @command_window.set_handler(:screen_size, method(:command_screen_size))
  end

  def command_screen_size
    SceneManager.call(Scene_ScreenSize)
  end
end

class Window_TitleCommand < Window_Command
  def make_command_list
    add_command(Vocab::new_game, :new_game)
    add_command(Vocab::continue, :continue, continue_enabled)
    add_command(Screen_Size::COMMAND_NAME, :screen_size)
    add_command(Vocab::shutdown, :shutdown)
  end
end

class Window_MenuCommand < Window_Command
  def make_command_list
    add_main_commands
    add_formation_command
    add_save_command
    add_screenSize_command
    add_game_end_command
  end

  def add_screenSize_command
    add_command(Screen_Size::COMMAND_NAME, :screen_size)
  end

  def main_commands_enabled
    $game_system.save_disabled ? false : true
  end
end

class Scene_Menu < Scene_MenuBase
  alias original_create_command_window create_command_window

  def create_command_window
    original_create_command_window
    @command_window.set_handler(:screen_size, method(:command_screen_size))
  end

  def command_screen_size
    SceneManager.call(Scene_ScreenSize)
  end
end

You can rename the option in the Screen_Size module if you want, and you can add, remove or change resolutions to your needs.

I found that some resolutions have some artefacts while others don't, so you probably want to adjust some of them.

I also found that working with multiples of 32 seem to have the best output. But it will work with any resolution nontheless. 🙂


EDIT :
To fix the title screen bug, you have to resize your images to 640x480 instead of 544x416, and there will be no more black borders. 🙂
Hello!! Thank you sooo much for answering!! I was very pessimistic about that!

So I paste this script on my project and this error shows up:
error1 xp.jpg



This is my RPG MAKER XP verison:
error2 xp.jpg

* I have tested it on a new project as well and the same error shows up.


Im sorry Im very layman on codes so I cant help much XD

Thank you so much for helping me!
The problem is that the script was crafted as if it would be used in a RMVX ACE game. Thus it will fail over and over again.
Hello @kyonides ! Thank you for answering!
Is there any way to make an adaptation for RPG Maker XP? The game dont even start in a blank project.
So it's not like it's something situational. Maybe it's a code error or it really needs some changes to work in RPG MAKER XP.

Or

you already tried something similar and found out it's impossible? Due RMXP limitations? xD

Whats your thoughts on this?
Oh my...
I actually thought it was for VX Ace xD

Well, I'll port it to Rpg maker XP tomorrow.
Sorry for the embarassing mistake...

Hello @kyonides ! Thank you for answering!
Is there any way to make an adaptation for RPG Maker XP? The game dont even start in a blank project.
So it's not like it's something situational. Maybe it's a code error or it really needs some changes to work in RPG MAKER XP.

Or

you already tried something similar and found out it's impossible? Due RMXP limitations? xD

Whats your thoughts on this?

It's possible, there isn't much that isn't possible.
I'll look into it for tomorrow. (Also, plz confirm you want it for RPG Maker XP )

VXAce uses ruby language
MV/MZ uses javascript
XP uses ruby language aswell, but has a different structure, hence the errors talking about undefined superclass Scene_MenuBase, as in XP they use Scene_Menu

Depending on what software you use I need to apply some changes. 🙂
Hello @Artille thank you sooo much!!! I am deeply grateful! This will help me soo much!
I suggest you try and see how things go if you use Alt+Enter to toggle between fullscreen and windowed mode. Just to check if that plays nice with window alteration via SetWindowPos calls.

An alternative approach is to look into MKXP. I really like the integer scaling Ancurio has implemented. You can read more about it here: https://wiki.mapleshrine.eu/books/configuration/page/integer-scaling
MKXP: https://github.com/mkxp-z/mkxp-z
I admit defeat and suggest you look for something more complete.

The best I can do is add black pixels in the new resolution.
I either run against RPG Maker XP limitations when it comes to pixel stretching
Or, if I try to leverage Win32 I get errors all around because current ruby version can't handle it.


This may be a key to solving this issue :

But honestly this is beyond my skills.
Rpgmaker XP just is too old and does not support pixel stretching, meaning we have to add dll files and deep scripting logic.
Hello @Zeriab thank you so much for answer! About the ALT+ENTER this is what another person told me "Fullscreen stretches because it's effectively changing your monitor's resolution to 640x480."

About the Ancurio's integer scaling I took a look but this does what others script does. They resize the screen indeed but they enlarge the screen but in view scale. Showing more of the map. None of them can stretch the screen while maintaining the aspect ratio. From what I read its sadly a RPG MAKER XP limitation.
@Artille thank you soo much for trying! I really apreciate it!!
I saw that thread and I asked help there as well xD
She told me this:
"From what I remember, XP's game window doesn't actually stretch when you increase its width or height, unlike VXA. It instead just displays a black void beyond the 640x480 default. Fullscreen stretches because it's effectively changing your monitor's resolution to 640x480. So you're not really going to achieve what you want with the default engine.

You'll need to either use VXA's game executable (points at XPAce in signature) or use something like MKXP(-z)"
I will ask help there for this "VXA's game executable", It seems like something that can be done.

I took a look at the other option MKXP(-z) but I didnt undestand too much to be honest. But it seems like there is anything about screensizes there. Maybe its something that can be done but only from scratch...



Do you know something about that "VXA's game executable"? Please let me know. Thank you so much for helping and answering!

Cheers!
That's not quite correct. The specific behavior of how the 640x480 in fullmode behaves depends on your drivers and display settings.

I have an Nvidia graphics card. It has the following scaling modes used to determine how lower resolutions are scaled to fit the actual display resolution:
  • Aspect ratio
  • Full-screen
  • No scaling
  • Integer scaling*
Ref: https://www.nvidia.com/content/Cont...s/mergedProjects/nvdsp/CS_Display_Scaling.htm

I have added a * to the Integer scaling option because in my experience you cannot rely on it being available. I have had the option being available before, and it works great. But look, I have a GeForce RTX 3080 card yet the option is currently not available for me:
1723185846032.png


You cannot be sure how the fullscreen mode behaves because it depends on the system settings.

Having the engine do the scaling is a more reliable way if you want to control how the scaling works.
To better explain how integer scaling works in MKXP here are two screenshots I took. (Note: You can freely resize the window in windowed mode)
Windowed mode: (2x)
integer-scaling-1.png
Fullscreen: (3x)
integer-scaling-2.png

Note that the linked pictures are what's rendered. These are not 640x480.

MKXP has other scaling options. Here's the default look:
normal-scaling.png
Smoothed and stretched:
smoothed-stretched.png


Personally I prefer retaining aspect ratio because the alternative looks like this:
1723188071304.png



For VX Ace there is an additional option: https://forums.rpgmakerweb.com/index.php?threads/rgd-directx-implementation-of-rgss3.95228/
I wonder if XPAce allows you to use that for an XP game.

Good luck with whichever path you choose ^^
Hello!! Thank you so much for the explanations! Im very busy these days. I will take a deep look into that next week! Looks very promising!

Wish you the best!

Original thread: https://forums.rpgmakerweb.com/threads/change-game-sizescreen-but-keep-640x480-stretched.170920/