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.

Resolution Changer VX

Status
Not open for further replies.
Resolution Changer VX
Version: 1.0


Introduction

I got frustrated by the lack of working Resolution Scripts. Normal ones just stretch the screen to the desired size, this one actually changes the size of the screen allowing you to fit more or less tiles on. It probably could also be used with ordinary resolution scripts to achieve any size you want - not been tested though.

Features
  • Resize the Game Window
  • Currently the max is 640×480 (whether I can change this I'm unsure)

Screenshots

A screen that's bigger?

Script

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(width,height)
#
#  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

Instructions

Put it under the Materials Section

Simply use the one line in main just below 'begin':

Graphics.resize_screen(width,height)

It is advised that you use screen sizes that are divisible by 32
This will reduce the amount of any Screen and picture related errors

You should also try and use sizes that have an odd number of tiles, but you don't need to

IMPORTANT!

If you resize your screen bigger than the standard make sure you make all your maps atleast that size.
DO NOT make any smaller than your screensize or you will see errors

Compatibility

Should work with most things, but I'm not 100% sure
I hope it works with other resolution scripts xD

You will have to resize ALL of you Scenes and Windows (except Scene_Map, that's been done)

Credits and Thanks

Me please xD

Author's Notes

I'm not sure if I've left anything out so please do report any errors ^_^
Read the script header before reporting any though!
 
I'm not sure exactly what you say this does. Does it change the window size, or does it change the in-game resolution? I just want to clarify, because those are two very different results. Window size is useful for various new formats, but can also be a problem for other reasons. (mostly mapping errors) On the other hand, resolution will change how things in the game display, allowing you to effectively use a classic 16x16 tileset without problems. This may have problems like changing the resolution of the entire screen, which must be scripted out.
 
Sorry for the poor naming, I made it quickly and wanted to post it.

Basically (like it says at the top), it allows you to fit more tiles on the screen, so changing the screensize.

It should work with resolution scripts that stretch/shrink the window too, I hope.
 
  $game_screen_width = 544
  $game_screen_height = 416
  $game_width_tiles = 17
  $game_height_tiles = 13

WHY do you have unneeded global variables?  Graphics.width/Graphics.height do the exact same thing without having to use global variables.  NEVER EVER EVER use global variables unless for $game_ and $data_!
 
I just looked closer at this script, and realized that in its current state, it is actually fairly useless. All it can really do is change how much of the window displays the game. It effectively shrinks the view within the window, leaving black bars on the right and bottom. What you need to do is use Win32API to actually change the window size, so that it can look like it is supposed to. I'm currently adapting this script to an old XP project I have, but I just wanted to comment on this. Also, if you do resize the window, be sure that you reset the position to the center using Win32API, so that it doesn't appear off center. (I have not yet tried expanding the view, although I assume it would not expand the window)
 
First, Yeyinde, like I said I made this script quickly. It was the first thing I put there and it work so I didn't bother going back to change it.

And Glitchfinder, no it doesn't just leave unneeded black space. I don't want it to stretch the game that was what I was trying it not to do. I made a script that made the screen bigger as well as making the map bigger. Thats what it does.
 
I guess you could call it an update...

I just changed the script to use 'Graphics' instead of global variables.

Which also made the 'Resolution' Module unnecessary so I removed that too.
 
First, i would avoid double-posting when possible. (It is against forum rules). Second, I mentioned that I was shrinking the screen. Although I am unfamiliar with the background programming with RMVX, I assume it is similar enough to RMXP that if you shrank the viewable area (like this script appears to be able to do), it will leave black bars. I may be wrong. RMVX may be programmed to chenge the screen size based on the specified viewport. Apparently, it does when you expand it. As I said, I did not test it with an expended viewing area, just a shrunk one. (In case you are wondering why, it would be because of a project I am working on for multiple screen sizes, to emulate classic 2D consoles and handhelds.) (GBA, SNES, NES, etc.) Oh, and I tested it in RMXP. I needed to make some modifications, though, so don't start with the [XP + VX] in the beginning of the thread like the Background Timer a few pages back.
 
Most forums you're allowed to 'double' post when it's an update, and was kinda an update. I know general rules for most forums and assume it applies to all of them. I should probably read them individually xD

Anywho, RMVX only has the coding to shrink the window, but obviously that'll leave all the scripting already done (scenes, maps etc.) the wrong size. This automatically changes the map and battle (and timer) positions and sizes. It doesn't leave any black spaces except when you don't resize your own images. For example the title will have black spaces only because the game doesn't automatically stretch the title image, you have to make it to fit.
And very important (like it says on the first page) you must make you maps the same size or bigger than the resolution or you will get a tiling effect, which you don't want.
 
As I was trying to say, I was unfamiliar with RMVX programming. I know for certain that in RMXP (which is where I have said I am using slightly modified version of this script), shrinking the screen with this script leaves black space, because the actual window size does not change. From what you are saying, this is untrue in RMVX. I apologize for any confusion, but it seems that they have not only made a great deal of mistakes building RMVX, they actually had some good ideas as well. Oh, and since I'm using this in RMXP, I might post a modified version of the script here that uses Win32API, so that it will work in RMXP. (from what I can tell, the RMXP-compatible version will be incomatible with RMVX due to some addons to the Game_Map class that didn't appear in RMXP)
 
kirbywarrior, please don't necropost. it's been 3 months since the last post.
Plus, syvkal hasn't been active since August 30. I'm locking this, so if you need help, ask in the RGSS Support forum.
 
Status
Not open for further replies.

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