Sujet n°5267
Posté par Schtroumpf Anarchiste le 27 Oct - 11:03 (2009)
Titre : [Script] Script taille GBA en x2
Bonjour à tous.

Alors voilà. J'ai voulu avoir pour mon jeu un écran de taille GBA, mais le 1x1 n'étant pas au point, j'ai décidé de laisser en x2, donc de vouloir avoir un écran de taille (240*2)*(160*2) soit 480*320. J'ai donc pris ce code que tout l'monde doit connaître, sur RPG creative :

Code:


#==============================================================================
# ¦ Win32API
#------------------------------------------------------------------------------
# by Squall squall@loeher.znn.com
# Change the window size
# I must thank cybersam for his mouse and keyboard scripts. they were very
# useful finding some winapi function.
#
# Ce script a été modifié par Sunmat pour une gestion fonctionnelle
# de la supperposition.
# les valeurs de la taille sont aux lignes 71 et 72
#==============================================================================

class Win32API
  #--------------------------------------------------------------------------
  # ? define constant
  #--------------------------------------------------------------------------
  GAME_INI_FILE = ".\Game.ini"         # define "Game.ini" file
  HWND_TOPMOST = 0                      # window always active
  HWND_TOP = -1                         # window active when used only
  SWP_NOMOVE   = 0                      # window pos and sizes can be changed
  #--------------------------------------------------------------------------
  # ? Win32API.GetPrivateProfileString // check your game title in Game.ini
  #--------------------------------------------------------------------------
  def Win32API.GetPrivateProfileString(section, key)
    val = "\0"*256
    gps = Win32API.new('kernel32', 'GetPrivateProfileString',%w(p p p p l p), 'l')
    gps.call(section, key, "", val, 256, GAME_INI_FILE)
    val.delete!("\0")
    return val
  end
  #--------------------------------------------------------------------------
  # ? Win32API.FindWindow // cherche la fenetre RGSS
  #--------------------------------------------------------------------------
  def Win32API.FindWindow(class_name, title)
    fw = Win32API.new('user32', 'FindWindow', %(p, p), 'i')
    hWnd = fw.call(class_name, title)
    return hWnd
  end
  #--------------------------------------------------------------------------
  # ? Win32API.SetWindowPos // change la position et la taille de la fenetre
  #--------------------------------------------------------------------------
  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)
   
    #la ligne si dessous correspond à la fenetre supérieur aux autres
    #win = swp.call(hWnd, HWND_TOPMOST, 0, 0, w + 6, h + 32, SWP_NOMOVE)
    return win
  end
  #--------------------------------------------------------------------------
  # ? Win32API.client_size // check the window width and height
  #--------------------------------------------------------------------------
  def Win32API.client_size
    title =  Win32API.GetPrivateProfileString("Game", "Title")
    hWnd = Win32API.FindWindow("RGSS Player", title)
    rect = [0, 0, 0, 0].pack('l4')
    Win32API.new('user32', 'GetClientRect', %w(l p), 'i').call(hWnd, rect)
    width, height = rect.unpack('l4')[2..3]
    return width, height
  end
end

#==============================================================================
# ¦ proceed with creation of the window
#------------------------------------------------------------------------------
# the width and height variables set the screen size.
#==============================================================================
$width = 480
$height = 320
win = Win32API.SetWindowPos($width, $height)
if(win == 0)
  p "Le changement de la taille de l'écran a échoué"
end

#==============================================================================
# ¦ Game_Player
#------------------------------------------------------------------------------
#  remade to be compatible with change sreen size scrîpt
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ? define constant
  #--------------------------------------------------------------------------
  CENTER_X = ($width/2 - 16) * 4    # X coordinate in the center of the screen
  CENTER_Y = ($height/2 - 16) * 4   # Y coordinate in the center of the screen
end

#==============================================================================
# ¦ Spriteset_Map //squall@loeher.zzn.com
#------------------------------------------------------------------------------
# remade to be compatible with change sreen size scrîpt
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # ? Initialize
  #--------------------------------------------------------------------------
  def initialize
    if $game_map.width >= 25 and $game_map.height >= 19
      $width2 = $width
      $height2 = $height
      elsif $game_map.width >= 25 and $game_map.height < 19
      $width2 = $width
      $height2 = 480
      elsif $game_map.width < 25 and $game_map.height >= 19
      $width2 = 640
      $height2 = $height
      elsif $game_map.width < 25 and $game_map.height < 19
      $width2 = 640
      $height2 = 480
    else
      $width2 = $width
      $height2 = $height
    end
    @viewport1 = Viewport.new(0, 0, $width2, $height2)
    @viewport2 = Viewport.new(0, 0, $width2, $height2)
    @viewport3 = Viewport.new(0, 0, $width2, $height2)
    @viewport4 = Viewport.new(640, 0, $width2-640, 480)
    @viewport5 = Viewport.new(0, 480, 640, $height2-480)
    @viewport6 = Viewport.new(640, 480, $width2-640, $height2-480)
   
    #@viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
   
    @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
   
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
   
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
   
    @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))
   
    @weather = RPG::Weather.new(@viewport1)
   
    @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
  #--------------------------------------------------------------------------
  # ? Dispose the sprite
  #--------------------------------------------------------------------------
  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
  #--------------------------------------------------------------------------
  # ? Update the sprite
  #--------------------------------------------------------------------------
  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
   
    #if @tilemap.ox > $game_map.width * 32 - $width
    #@tilemap.ox = $game_map.width * 32 - $width
    #end
    #if @tilemap.oy > $game_map.width * 32 - $height
    #@tilemap.oy = $game_map.height * 32 - $height
    #end
   
    @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
   
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    @viewport3.color = $game_screen.flash_color
    @viewport1.update
    @viewport3.update
  end
end
class Game_Map
  #--------------------------------------------------------------------------
  # ? Scroll the map down
  #     distance : Distance to scroll in real units (4 = 1 pixel).
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    if $height / 32.0 < self.height - 1
      @display_y = [@display_y + distance, (self.height - ($height / 32.0)) * 128].min
    else
      @display_y = [@display_y + distance, (self.height - 15) * 128].min
    end
  end
  #--------------------------------------------------------------------------
  # ? Scroll the map left
  #     distance : Distance to scroll in real units (4 = 1 pixel).
  #--------------------------------------------------------------------------
  def scroll_left(distance)
    @display_x = [@display_x - distance, 0].max
  end
  #--------------------------------------------------------------------------
  # ? Scroll the map right
  #     distance : Distance to scroll in real units (4 = 1 pixel).
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    if $width / 32.0 < self.width - 1
      @display_x = [@display_x + distance, (self.width - ($width / 32.0)) * 128].min
    else
      @display_x = [@display_x + distance, (self.width - 20) * 128].min
    end
  end
  #--------------------------------------------------------------------------
  # ? Scroll the map up
  #     distance : Distance to scroll in real units (4 = 1 pixel).
  #--------------------------------------------------------------------------
  def scroll_up(distance)
    @display_y = [@display_y - distance, 0].max
  end
end


Le problème, c'est que mon écran de jeu est bien de la taille voulue, mais pas la fenêtre.
Screen :

Spoiler


Et l'erreur comme indiquée à la ligne 75 :

Spoiler


Voilà, si quelqu'un pouvait savoir comment faire pour que la fenêtre aussi soit en 480*320.
Merci d'avance.

PS : J'ai déjà regardé le topic " redimentionner la taille du jeu " de Zelda, mais le script fourni par Palbolsky n'a aucun effet chez moi ( il marche mais n'a aucun effet, ça change rien en gros ).

Posté par Warp' le 27 Oct - 20:27 (2009)
Il y a un problème, se script ne redimmensionnera pas les fenêtres de combats. Tout les scripts de combats seront a recommencer..

Posté par Schtroumpf Anarchiste le 27 Oct - 20:31 (2009)
Ah, en combat, j'ai pas essayé :s