[PSDK] Utiliser des ressources HD

3 Réponses • 765 Vues

Nuri Yuri

HostMaster

Salut, par défaut PSDK tourne en SD (320x240), si vous désirez utiliser des ressources HD j'ai crée un script qui devrait vous simplifier le tâche en terme de modification, vous donnez juste la résolution finale de votre jeu et il ajuste les paramètres !

Attention, ce script ne modifie pas les interface, c'est votre boulot.
# This script aim to set PSDK in a 32x32 resolution instead of the 16x16 one
# The screen will then be in 640x480 and the viewports will be in 640x480 (you can choose the resolution)

# Define the default width of the screen
screen_width = 640
# Define the default height of the screen
screen_height = 480
# Set the following variable to true if you want the ox_offset & oy_offset of particles to be doubled, set to false otherwise
double_particle_offset = true
# Force the rect: action of the particle to fix oy to the height
force_particle_rect_oy = true

#===
# Begining of the scrip
# Don't edit the lines after this comment!
#===
$global_binding = binding
# Config edit
module Config
  # Change the screen width
  remove_const :ScreenWidth
  ScreenWidth = $global_binding.local_variable_get(:screen_width)
  # Change the screen height
  remove_const :ScreenHeight
  ScreenHeight = $global_binding.local_variable_get(:screen_height)
  # Change the specific zoom
  remove_const :Specific_Zoom
  Specific_Zoom = 1
  # Change the default scale
  if ARGV.grep(/scale=/).empty?
    remove_const :ScreenScale
    const_set :ScreenScale, 1
  end
  # Change the main viewport properties
  module Viewport
  # Change the width
  remove_const :Width
  Width = $global_binding.local_variable_get(:screen_width)
  # Change the height
  remove_const :Height
  Height = $global_binding.local_variable_get(:screen_height)
  end
end

# Force the tilemap to be the RMXP one
class Spriteset_Map
  # Return the prefered tilemap class
  # @return [Class]
  def tilemap_class
    return Tilemap::WithLessRubySprites
  end
end

# Adjust the game player center X/Y position
class Game_Player
  remove_const :CENTER_X
  remove_const :CENTER_Y
  CENTER_X = ($global_binding.local_variable_get(:screen_width) / 2 - 16) * 4
  CENTER_Y = ($global_binding.local_variable_get(:screen_height) / 2 - 16) * 4
end

# Fix the shadow & the screen x/y
class Game_Character
  # Return the x position of the shadow of the character on the screen
  # @return [Integer]
  def shadow_screen_x
    return (@real_x - $game_map.display_x + 3) / 4 + 16 # +3 => +5
  end

  # Return the y position of the shadow of the character on the screen
  # @return [Integer]
  def shadow_screen_y
    return (@real_y - $game_map.display_y + 3) / 4 + 32 + (@offset_shadow_screen_y || 0) # +3 => +5
  end

  # Return the x position of the sprite on the screen
  # @return [Integer]
  def screen_x
    return (@real_x - $game_map.display_x + 3) / 4 + 16
  end

  # Return the y position of the sprite on the screen
  # @return [Integer]
  def screen_y
    y = (@real_y - $game_map.display_y + 3) / 4 + 32 # +3 => +5
    y += @offset_screen_y if @offset_screen_y
    if @jump_count >= @jump_peak
      n = @jump_count - @jump_peak
    else
      n = @jump_peak - @jump_count
    end
    return y - (@jump_peak * @jump_peak - n * n) / 2
  end
end

# Fix the tile zoom
class Sprite_Character
  remove_const :TILE_ZOOM
  TILE_ZOOM = 1
end

# Ajust the MapLinker offset
module Yuki
  module MapLinker
    remove_const :OffsetX
    remove_const :OffsetY
    OffsetX = ($global_binding.local_variable_get(:screen_width) / 64.0).ceil
    OffsetY = ($global_binding.local_variable_get(:screen_height) / 64.0).ceil
  end
end

# Ajust the tilemap script
class Tilemap
  remove_const :NX
  remove_const :NY
  NX = ($global_binding.local_variable_get(:screen_width) / 32.0).ceil + 2
  NY = ($global_binding.local_variable_get(:screen_height) / 32.0).ceil + 2
end

# Fix the particles
module Yuki
  class Particle_Object
    # Update the position of the particle sprite
    def update_sprite_position
      case @position_type
      when :center_pos, :grass_pos
        @sprite.x = ((@x * 128 - $game_map.display_x + 3) / 4 + 16)
        @sprite.y = ((@y * 128 - $game_map.display_y + 3) / 4 + 32)
        if @position_type == :center_pos || @sprite.y >= @character.screen_y
          @sprite.z = (screen_z + @add_z)
        else
          @sprite.z = (screen_z - 1)
        end
        @sprite.ox = @ox + @ox_off
        @sprite.oy = @oy + @oy_off
      when :character_pos
        @sprite.x = @character.screen_x / @zoom
        @sprite.y = @character.screen_y / @zoom
        @sprite.z = (@character.screen_z(0) + @add_z)
        @sprite.ox = @ox + @ox_off
        @sprite.oy = @oy + @oy_off
      end
    end

    if $global_binding.local_variable_get(:force_particle_rect_oy)
      add_handler(:rect) do |data|
        @sprite.src_rect.set(*data)
        @ox = data[2] / 2
        @oy = data[3]
      end
    end

    if $global_binding.local_variable_get(:double_particle_offset)
      add_handler(:oy_offset) { |data| @oy_off = data&.*(2) }
      add_handler(:ox_offset) { |data| @ox_off = data&.*(2) }
    end
  end
end

Enregistrez ce script dans le dossier scripts à la racine de votre projet sous le nom 00900 NuriYuri 32x32 Res.rb.

« Modifié: 16 mars 2019, 11:07:27 par Nuri Yuri »

ln(yo) = <3

Nuri Yuri

HostMaster

Si vous ne désirez pas refaire les interfaces, vous pouvez utiliser le script suivant :
# This script can be used with 00900 NuriYuri 32x32 Res.rb
# It makes your UI 2 times bigger in their viewport

# Define the original width of the screen (when you made your UI)
screen_width = 320
# Define the original height of the screen (when you made your UI)
screen_height = 240
# Set the following variable to true to also double the size of the Message Window
double_message_window = true

#===
# Begining of the scrip
# Don't edit the lines after this comment!
#===
$global_binding = binding
# Fix the viewport of the GamePlay:: Scene
module GamePlay
  class Base
    O_SCREEN_WIDTH = $global_binding.local_variable_get(:screen_width)
    O_SCREEN_HEIGHT = $global_binding.local_variable_get(:screen_height)
    # The main process at the begin of scene
    def main_begin
      if @viewport
        @viewport.ox = - O_SCREEN_WIDTH / 2
        @viewport.oy = - O_SCREEN_HEIGHT / 2
        @viewport.zoom = 2
      end
      Graphics.transition
    end
  end
end

if double_message_window
  module Yuki
    class Message
      O_SCREEN_WIDTH = $global_binding.local_variable_get(:screen_width)
      O_SCREEN_HEIGHT = $global_binding.local_variable_get(:screen_height)
      alias old_initialize initialize
      # Create a new Message handler
      # @param viewport [LiteRGSS::Viewport]
      # @param parent [GamePlay::Base, Scene_Map]
      def initialize(viewport, parent = $scene)
        old_initialize(viewport, parent)
        viewport.ox = - O_SCREEN_WIDTH / 2
        viewport.oy = - O_SCREEN_HEIGHT / 2
        viewport.zoom = 2
      end
     
      # Return the default window width
      # @return [Integer]
      def default_width
        viewport.rect.width / 2 - default_horizontal_margin * 2
      end

      # Calculate the current window position
      def calculate_position
        x = default_horizontal_margin
        case current_position
        when :top
          y = default_vertical_margin
        when :middle
          y = (viewport.rect.height / 2 - height) / 2
        when :bottom, :left
          y = viewport.rect.height / 2 - default_vertical_margin - height
        when :right
          y = viewport.rect.height / 2 - default_vertical_margin - height
          x = viewport.rect.height / 2 - x - width
        end
        set_position(x, y)
      end
    end
  end
end

Enregistrez ce script dans le dossier scripts à la racine de votre projet sous le nom 00901 NuriYuri Double_UI_Viewport_Size.rb.

Attention, ce script n'affecte pas l'écran titre, la sauvegarde et les combats. Pour les combats ça sera surement affecté en Alpha 25.
ln(yo) = <3
Premier à répondre et à adorer le post.
Merci Nuri Yuri pour le temps consacré au partage de ces deux scripts (avec et sans interface)  (a)
(Maintenant, je n'ai plus d'excuse pour ne plus réussir à passer le PSDK en mode HD par mes propres moyens.)
(Dsl du Nécro-post, mais je devais absolument remercier Yuri)

Merci beaucoup pour ce magnifique script ! Je cherchais depuis quelques temps comment afficher les UI en HD, et voila la solution Miracle ! Merci a Arceus d'avoir créé une personne si cool que Yuri.


There was an error while thanking
Thanking...