게임화면의 해상도를 변경하는 스크립트

by 제로스S2 posted Aug 06, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제

이실형이 만들었다네요....

 

5번째 줄과 6번째 줄을이용해 해상도를 조정할수있습니다.... ^^

 

유용히쓰세요 ^^

 

#====================바로밑줄부터복사=====================#

 

# Written by Squall (squall@loeher.znn.com)
# 할 일: 1. GetSystemMetrics 함수
#        2. ??

WINDOW_WIDTH = 1020
WINDOW_HEIGHT = 740
class Win32API
  GAME_INI_FILE = ".Game.ini"
  HWND_TOPMOST = 0
  HWND_TOP = -1
  SWP_NOMOVE = 0
  def Win32API.GetPrivateProfileString(section, key)
    val = "" * 256
    gps = Win32API.new("kernel32", "GetPrivateProfileString", ['P', 'P', 'P', 'P', 'L', 'P'], 'L')
    gps.call(section, key, '', val, 256, GAME_INI_FILE)
    val.delete!("")
    return val
  end
  def Win32API.FindWindow(class_name, title)
    fw = Win32API.new("user32", "FindWindow", ['P', 'P'], 'I')
    hwnd = fw.call(class_name, title)
    return hwnd
  end
  def Win32API.SetWindowPos(w, h)
    title = Win32API.GetPrivateProfileString("Game", "Title")
    hwnd = Win32API.FindWindow("RGSS Player", title)
    swp = Win32API.new("user32", "SetWindowPos", ['L', 'L', 'I', 'I', 'I', 'I', 'I'], 'I')
    win = swp.call(hwnd, HWND_TOP, 0, 0, w + 6, h + 32, 0)
#    win = swp.call(hwnd, HWND_TOPMOST, 0, 0, w + 6, h + 32, SWP_NOMOVE)
    return win
  end
end
$window_width = WINDOW_WIDTH
$window_height = WINDOW_HEIGHT
class Game_Map
  def scroll_down(distance)
    if $window_height / 32.0 < self.height - 1
      @display_y = [@display_y + distance, (self.height - ($window_height / 32.0)) * 128].min
    else
      @display_y = [@display_y + distance, (self.height - 15) * 128].min
    end
  end
  def scroll_left(distance)
    @display_x = [@display_x - distance, 0].max
  end
  def scroll_right(distance)
    if $window_width / 32.0 < self.width - 1
      @display_x = [@display_x + distance, (self.width - ($window_width / 32.0)) * 128].min
    else
      @display_x = [@display_x + distance, (self.width - 20) * 128].min
    end
  end
  def scroll_up(distance)
    @display_y = [@display_y - distance, 0].max
  end
end
class Game_Player < Game_Character
  CENTER_X = ($window_width / 2 - 16) * 4
  CENTER_Y = ($window_height / 2 - 16) * 4
end
class Spriteset_Map
  def initialize
    if $game_map.width >= 25 and $game_map.height >= 19
      $window_width2 = $window_width
      $window_height2 = $window_height
    elsif $game_map.width >= 25 and $game_map.height < 19
      $window_width2 = $window_width
      $window_height2 = 480
    elsif $game_map.width < 25 and $game_map.height >= 19
      $window_width2 = 640
      $window_height2 = $window_height
    elsif $game_map.width < 25 and $game_map.height < 19
      $window_width2 = 640
      $window_height2 = 480
    else
      $window_width2 = $window_width
      $window_height2 = $window_height
    end
    @viewport1 = Viewport.new(0, 0, $window_width2, $window_height2)
    @viewport2 = Viewport.new(0, 0, $window_width2, $window_height2)
    @viewport3 = Viewport.new(0, 0, $window_width2, $window_height2)
    @viewport4 = Viewport.new(640, 0, $window_width2 - 640, 480)
    @viewport5 = Viewport.new(0, 480, 640, $window_height2 - 480)
    @viewport6 = Viewport.new(640, 480, $window_width2 - 640, $window_height2 - 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    @tilemap = Tilemap.new(@viewport2)
    @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
    @panorama = Plane.new(@viewport2)
    @panorama.z = -1000
    @fog = Plane.new(@viewport2)
    @fog.z = 3000
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport2, $game_map.events[i])
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport2, $game_player))
    @weather = RPG::Weather.new(@viewport2)
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i]))
    end
    @timer_sprite = Sprite_Timer.new
    @tilemap2 = Tilemap.new(@viewport4)
    @tilemap2.tileset = RPG::Cache.tileset($game_map.tileset_name)
    @tilemap3 = Tilemap.new(@viewport5)
    @tilemap3.tileset = RPG::Cache.tileset($game_map.tileset_name)
    @tilemap4 = Tilemap.new(@viewport6)
    @tilemap4.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names[i]
      @tilemap2.autotiles[i] = RPG::Cache.autotile(autotile_name)
      @tilemap3.autotiles[i] = RPG::Cache.autotile(autotile_name)
      @tilemap4.autotiles[i] = RPG::Cache.autotile(autotile_name)
    end
    @tilemap2.map_data = $game_map.data
    @tilemap3.map_data = $game_map.data
    @tilemap4.map_data = $game_map.data
    update
  end
  def dispose
    @tilemap.tileset.dispose
    @tilemap2.tileset.dispose
    @tilemap3.tileset.dispose
    @tilemap4.tileset.dispose
    for i in 0..6
      @tilemap.autotiles[i].dispose
      @tilemap2.autotiles[i].dispose
      @tilemap3.autotiles[i].dispose
      @tilemap4.autotiles[i].dispose
    end
    @tilemap.dispose
    @tilemap2.dispose
    @tilemap3.dispose
    @tilemap4.dispose
    @panorama.dispose
    @fog.dispose
    for sprite in @character_sprites
      sprite.dispose
    end
    @weather.dispose
    for sprite in @picture_sprites
      sprite.dispose
    end
    @timer_sprite.dispose
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
    @viewport4.dispose
    @viewport5.dispose
    @viewport6.dispose
  end
  def update
    if @panorama_name != $game_map.panorama_name or
       @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end
    @tilemap.ox = $game_map.display_x / 4
    @tilemap.oy = $game_map.display_y / 4
    @tilemap.update
    @tilemap2.ox = @tilemap.ox + 640
    @tilemap2.oy = @tilemap.oy
    @tilemap2.update
    @tilemap3.ox = @tilemap.ox
    @tilemap3.oy = @tilemap.oy + 480
    @tilemap3.update
    @tilemap4.ox = @tilemap.ox + 640
    @tilemap4.oy = @tilemap.oy + 480
    @tilemap4.update
    @panorama.ox = $game_map.display_x / 8
    @panorama.oy = $game_map.display_y / 8
    @fog.zoom_x = $game_map.fog_zoom / 100.0
    @fog.zoom_y = $game_map.fog_zoom / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone
    for sprite in @character_sprites
      sprite.update
    end
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    for sprite in @picture_sprites
      sprite.update
    end
    @timer_sprite.update
    @viewport3.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    @viewport3.color = $game_screen.flash_color
    @viewport1.update
    @viewport3.update
   
    win = Win32API.SetWindowPos($window_width, $window_height)
    if win == 0
      print("창 크기 변경에 실패하였습니다.")
      exit
    end
  end
end
#ㅇ이거 ㅗ좀 쩔드라 ㅋㅋㅋㅋㅋ뻉바밥ㅏㅂ뺴

 

#==========================위에까지복사=============================#