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.

srcipt resolution changing (XP to VXACE)

hello

I wish I could change the resolution to do in my game rpgmaker vxace.
has the time or I use rpg maker xp I use this script that is exactly what I want:

Code:
# Resolution Changer Ultimate v1.1

# Script créé par Zeus81

#

#

#

#

 

class << Graphics

  def width ; return 1024; end # Configurez ici la largeur de l'écran

  def height; return 768; end # Configurez ici la hauteur de l'écran

  Fullscreen_Start = false    # Configurez ici si le jeu démarre en mode plein écran (true) ou pas (false)

  

  FindWindow       = Win32API.new("user32", "FindWindow", "pp", "l")

  CreateWindowEx   = Win32API.new("user32", "CreateWindowEx", "lpplllllllll", "l")

  UpdateWindow     = Win32API.new("user32", "UpdateWindow", "l", "l")

  ShowWindow       = Win32API.new("user32", "ShowWindow", "ll", "l")

  SetWindowLong    = Win32API.new("user32", "SetWindowLong", "lll", "l")

  SetWindowPos     = Win32API.new("user32", "SetWindowPos", "lllllll", "l")

  GetSystemMetrics = Win32API.new("user32", "GetSystemMetrics", "l", "l")

  GetDC            = Win32API.new("user32", "GetDC", "l", "l")

  FillRect         = Win32API.new("user32", "FillRect", "lpl", "l")

  SetKeyState      = Win32API.new("user32", "keybd_event", "llll", "")

  CreateSolidBrush = Win32API.new("gdi32", "CreateSolidBrush", "l", "l")

  SetResolution    = Win32API.new("Display", "SetResolution", "lll", "l")

  Screenshot       = Win32API.new("Screenshot", "Screenshot", "llllpll", "")

  Resolutions = [[], []]

  Resolutions[0].push([ 320,  240])

  Resolutions[0].push([ 640,  480])

  Resolutions[0].push([ 768,  576])

  Resolutions[0].push([ 800,  600])

  Resolutions[0].push([1024,  768])

  Resolutions[0].push([1152,  864])

  Resolutions[0].push([1280,  960])

  Resolutions[0].push([1280, 1024])

  Resolutions[0].push([1400, 1050])

  Resolutions[0].push([1600, 1200])

  Resolutions[0].push([2048, 1536])

  Resolutions[0].push([2560, 1920])

  Resolutions[0].push([2560, 2048])

  Resolutions[1].push([ 320,  200])

  Resolutions[1].push([ 800,  480])

  Resolutions[1].push([ 854,  480])

  Resolutions[1].push([ 960,  600])

  Resolutions[1].push([1088,  612])

  Resolutions[1].push([1280,  720])

  Resolutions[1].push([1280,  768])

  Resolutions[1].push([1280,  800])

  Resolutions[1].push([1360,  768])

  Resolutions[1].push([1440,  900])

  Resolutions[1].push([1680, 1050])

  Resolutions[1].push([1920, 1080])

  Resolutions[1].push([1920, 1200])

  Resolutions[1].push([2560, 1440])

  Resolutions[1].push([2560, 1600])

  Transition = Sprite.new

  Transition.z = 0xFFFF

  First_Start = !defined?(First_Start)

  if First_Start

    open("Game.ini") {|file| file.read[/Title=(.*?)\n/]}

    WindowHandle     = FindWindow.call("RGSS Player", $1)

    BackWindowHandle = CreateWindowEx.call(0x08000000, "Static", "", 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0)

    FillRectArgs = [GetDC.call(BackWindowHandle), [0,0,0xFFFF,0xFFFF].pack("l4"), CreateSolidBrush.call(0)]

    @@fullscreen, @@client_resolution = nil

    alias :zeus81_rcu_graphics_freeze     :freeze

    alias :zeus81_rcu_graphics_transition :transition

    alias :zeus81_rcu_graphics_update     :update

  end

  def update

    zeus81_rcu_graphics_update

    set_key_state(164, false)

    change_mode if Input.trigger?(Input::F5)

  end

  def freeze

    if width <= 640 and height <= 480; zeus81_rcu_graphics_freeze

    else

      Screenshot.call(0, 0, width, height, "freeze.bmp", WindowHandle, 0)

      Transition.bitmap = Bitmap.new("freeze.bmp")

      File.delete("freeze.bmp")

    end

  end

  def transition(d=8, f="", v=40)

    if width <= 640 and height <= 480; zeus81_rcu_graphics_transition(d, f, v)

    else

      d.times {|i| Transition.opacity = 256 - i*256/d; update}

      Transition.bitmap.dispose if Transition.bitmap

      Transition.bitmap, Transition.opacity = nil, 255

    end

  end

  def fullscreen?; return @@fullscreen; end

  def change_mode; set_resolution(!@@fullscreen); end

  def fullscreen_mode; set_resolution(true) unless @@fullscreen == true; end

  def windowed_mode; set_resolution(false) unless @@fullscreen == false; end

  private

  def set_key_state(k, b); SetKeyState.call(k, 0, (b ? 0 : 2), 0); end

  def get_resolution; return GetSystemMetrics.call(0), GetSystemMetrics.call(1); end

  def set_resolution(fullscreen)

    @@client_resolution = get_resolution unless @@fullscreen == true

    @@fullscreen = fullscreen

    w, h, z, f =  width, height, -1, 64

    if @@fullscreen

      ShowWindow.call(BackWindowHandle, 3)

      SetWindowLong.call(WindowHandle, -16, 0x14000000)

      ratio = @@client_resolution[0] / @@client_resolution[1].to_f

      for res in Resolutions[ratio < 1.5 ? 0 : 1]

        next unless res[0] >= width and res[1] >= height

        SetResolution.call(res[0], res[1], 4)

        break if res == get_resolution

      end

    else

      ShowWindow.call(BackWindowHandle, 0)

      SetWindowLong.call(WindowHandle, -16, 0x14CA0000)

      SetResolution.call(@@client_resolution[0], @@client_resolution[1], 0)

      w += (GetSystemMetrics.call(5)+2) * 2

      h += (GetSystemMetrics.call(6)+2) * 2 + GetSystemMetrics.call(4)

      z = f = 0

    end

    x, y = get_resolution

    x, y = [(x-w)/2, 0].max, [(y-h)/2, 0].max

    SetWindowPos.call(WindowHandle, z, x, y, w, h, f)

    UpdateWindow.call(BackWindowHandle)

    FillRect.call(*FillRectArgs)

  end

  Fullscreen_Start ? Graphics.fullscreen_mode : Graphics.windowed_mode if First_Start

end

 

class RPG::Weather

  def update

    return if @type == 0

    for i in 1..@max

      sprite = @sprites[i]

      break if sprite == nil

      case @type

      when 1; sprite.x -= 2; sprite.y += 16; sprite.opacity -= 8

      when 2; sprite.x -= 8; sprite.y += 16; sprite.opacity -= 12

      when 3; sprite.x -= 2; sprite.y +=  8; sprite.opacity -= 8

      end

      x, y = sprite.x - @ox, sprite.y - @oy

      if sprite.opacity < 64 or x < -50 or x > Graphics.width+110 or y < -300 or y > Graphics.height+20

        sprite.x, sprite.y = rand(Graphics.width+160)- 50+@ox, rand(Graphics.height+220)-200+@oy

        sprite.opacity = 255

      end

    end

  end

end

 

class Game_Map

  def scroll_right(distance); self.display_x += distance; end

  def scroll_left(distance) ; self.display_x -= distance; end

  def scroll_down(distance) ; self.display_y += distance; end

  def scroll_up(distance)   ; self.display_y -= distance; end

  def display_x=(x); @display_x = middle(0, x, width*128-Graphics.width*4) if @display_x != x and width*32 > Graphics.width; end

  def display_y=(y); @display_y = middle(0, y, height*128-Graphics.height*4) if @display_y != y and height*32 > Graphics.height; end

  def middle(min, x, max); return (x > min ? x < max ? x : max : min); end

  end

  

class Game_Event

  def visible; return !@event.name.include?("[INVISIBLE]"); end

end

 

class Game_Player

  CENTER_X, CENTER_Y = (Graphics.width/2-16)*4, (Graphics.height/2-16)*4

  def center(x, y); $game_map.display_x, $game_map.display_y = x*128-CENTER_X, y*128-CENTER_Y; end

end

 

class Sprite_Character

  attr_accessor :animation_viewport, :clones

  def initialize(a, b); super(a); @character, @clones = b, []; end

  alias :zeus81_rcu_sprite_character_update :update

  def update; zeus81_rcu_sprite_character_update; @clones.each {|c| c.update}; end

  def dispose; super; @clones.each {|c| c.dispose}; end

  def flash(a, b); super; @clones.each {|c| c.flash(a, b)}; end

  def bitmap=(a); (super; @clones.each {|c| c.bitmap=a}) if bitmap != a; end

  def visible=(a); (super; @clones.each {|c| c.visible=a}) if visible != a; end

  def opacity=(a); (super; @clones.each {|c| c.opacity=a}) if opacity != a; end

  def src_rect=(a); super; @clones.each {|c| c.src_rect=a}; end

  def ox=(a); (super; @clones.each {|c| c.ox=a}) if ox != a; end

  def oy=(a); (super; @clones.each {|c| c.oy=a}) if oy != a; end

  def x=(a); (super; @clones.each {|c| c.x=a-c.viewport.rect.x+viewport.rect.x}) if x != a; end

  def y=(a); (super; @clones.each {|c| c.y=a-c.viewport.rect.y+viewport.rect.y}) if y != a; end

  def z=(a); (super; @clones.each {|c| c.z=a-c.viewport.rect.y+viewport.rect.y}) if z != a; end

  def blend_type=(a); (super; @clones.each {|c| c.blend_type=a}) if blend_type != a; end

  def bush_depth=(a); (super; @clones.each {|c| c.bush_depth=a}) if bush_depth != a; end

  def animation(animation, hit)

    dispose_animation

    @_animation = animation

    return if @_animation == nil

    @_animation_hit, @_animation_duration = hit, @_animation.frame_max

    bitmap = RPG::Cache.animation(@_animation.animation_name, @_animation.animation_hue)

    if @@_reference_count.include?(bitmap); @@_reference_count[bitmap] += 1

    else; @@_reference_count[bitmap] = 1

    end

    @_animation_sprites = []

    if @_animation.position != 3 or not @@_animations.include?(@_animation)

      16.times do

        sprite = ::Sprite.new(@animation_viewport)

        sprite.bitmap, sprite.visible = bitmap, false

        @_animation_sprites.push(sprite)

      end

      @@_animations.push(@_animation) unless @@_animations.include?(@_animation)

    end

    update_animation

  end

end

 

class Spriteset_Map

  def initialize

    @tilemaps, @panoramas, @fogs, @character_sprites, @picture_sprites = [], [], [], [], []

    r = Rect.new(0, 0, [$game_map.width*32, Graphics.width].min, [$game_map.height*32, Graphics.height].min)

    r.x, r.y = (Graphics.width-r.width)/2, (Graphics.height-r.height)/2

    iw, ih = (r.width/640.0).ceil, (r.height/480.0).ceil

    for i in 0...iw*ih

      x, y = i%iw*640, i/iw*480

      w, h = [r.width-x, r.width, 640].min, [r.height-y, r.height, 480].min

      v = Viewport.new(r.x+x, r.y+y, w, h)

      @tilemaps.push(Tilemap.new(v))

      @tilemaps[-1].tileset = RPG::Cache.tileset($game_map.tileset_name)

      7.times {|j| @tilemaps[-1].autotiles[j] = RPG::Cache.autotile($game_map.autotile_names[j])}

      @tilemaps[-1].map_data, @tilemaps[-1].priorities = $game_map.data, $game_map.priorities

      @panoramas.push(Plane.new(v))

      @fogs.push(Plane.new(v))

      @panoramas[-1].z, @fogs[-1].z = -1000, 3000

      if i == 0

        $game_map.events.each_value {|e| @character_sprites.push(Sprite_Character.new(v, e)) if e.visible}

        @character_sprites.push(Sprite_Character.new(v, $game_player))

      else; @character_sprites.each {|s| s.clones.push(Sprite.new(v))}

      end

    end

    @viewport1, @viewport2, @viewport3 = Viewport.new(r), Viewport.new(r), Viewport.new(r)

    @viewport2.z, @viewport3.z = 200, 5000

    @weather = RPG::Weather.new(@viewport1)

    @character_sprites.each {|s| s.animation_viewport=@viewport1; s.update}

    (1..50).each {|i| @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i]))}

    @timer_sprite = Sprite_Timer.new

    update

  end

  def dispose

    @tilemaps[0].tileset.dispose

    7.times {|i| @tilemaps[0].autotiles[i].dispose}

    @tilemaps.each {|tilemap| tilemap.viewport.dispose; tilemap.dispose}

    @panoramas.each {|panorama| panorama.dispose}

    @fogs.each {|fog| fog.dispose}

    @character_sprites.each {|sprite| sprite.dispose}

    @weather.dispose

    @picture_sprites.each {|sprite| sprite.dispose}

    @timer_sprite.dispose

    @viewport1.dispose

    @viewport2.dispose

    @viewport3.dispose

  end

  def update

    if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue

      @panorama_name, @panorama_hue = $game_map.panorama_name, $game_map.panorama_hue

      @panoramas[0].bitmap.dispose if @panoramas[0].bitmap

      @panoramas[0].bitmap = (@panorama_name == "" ? nil : RPG::Cache.panorama(@panorama_name, @panorama_hue))

      @panoramas.each {|panorama| panorama.bitmap = @panoramas[0].bitmap}

      Graphics.frame_reset

    end

    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue

      @fog_name, @fog_hue = $game_map.fog_name, $game_map.fog_hue

      @fogs[0].bitmap.dispose if @fogs[0].bitmap

      @fogs[0].bitmap = (@fog_name == "" ? nil : RPG::Cache.fog(@fog_name, @fog_hue))

      @fogs.each {|fog| fog.bitmap = @fogs[0].bitmap}

      Graphics.frame_reset

    end

    @viewport1.tone, @viewport1.ox, @viewport3.color = $game_screen.tone, $game_screen.shake, $game_screen.flash_color

    @viewport1.update

    @viewport3.update

    ox, oy = $game_map.display_x/4, $game_map.display_y/4

    for i in [email=0...@tilemaps.size]0...@tilemaps.size[/email]

      tilemap = @tilemaps[i]

      tilemap.viewport.tone, tilemap.viewport.ox = @viewport1.tone, @viewport1.ox

      tilemap.viewport.update

      tilemap.ox = [email=ox+tilemap.viewport.rect.x-@viewport1.rect.x]ox+tilemap.viewport.rect.x-@viewport1.rect.x[/email]

      tilemap.oy = [email=oy+tilemap.viewport.rect.y-@viewport1.rect.y]oy+tilemap.viewport.rect.y-@viewport1.rect.y[/email]

      tilemap.update

      panorama = @panoramas[i]

      panorama.ox, panorama.oy = tilemap.ox/2, tilemap.oy/2 if panorama.bitmap

      fog = @fogs[i]

      if fog.bitmap

        fog.ox, fog.oy = tilemap.ox+$game_map.fog_ox, tilemap.oy+$game_map.fog_oy

        fog.zoom_x, fog.zoom_y = $game_map.fog_zoom/100.0, $game_map.fog_zoom/100.0

        fog.opacity, fog.blend_type, fog.tone = $game_map.fog_opacity, $game_map.fog_blend_type, $game_map.fog_tone

      end

    end

    @character_sprites.each {|sprite| sprite.update}

    @weather.type, @weather.max = $game_screen.weather_type, $game_screen.weather_max

    @weather.ox, @weather.oy = ox, oy

    @weather.update

    @picture_sprites.each {|sprite| sprite.update}

    @timer_sprite.update

  end

end

 

you would need its file to make it work:
http://www.mediafire.com/?9jsbd1jyq70fgy4

I intend to do fonctioné my game in 1024 * 768

sorry for my pitiful English, I am French ^ ^
 

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