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.

[VX]Splash Screens

Reliez

Member

Hi there, I was wondering if someone could make a splash screen script for RMVX.
I know there's already one for XP, but it doesn't work on VX ( because of compatibility).
So could someone make a script similar to the XP one, but making it compatible with VX?

Basically, before the game goes to the title screen, it display splash screen (preferably from the system folder) named like "Splash-01, 02, 03" and display them in the order named, and with each, plays a SE, all taking about 4 seconds per slide. Finally after the splash screens are displayed, it goes to the title.
Is it possible?
 

khmp

Sponsor

Code:
#==============================================================================
# ** Scene_Splash
#------------------------------------------------------------------------------
#  This class performs the splash screen processing.
#==============================================================================

class Scene_Splash < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Splash_Image_Prefix = 'Splash'    # Splash Images begin with what string
  Splash_Dir = 'Graphics/Pictures/' # Directory where the splash images are
  Seconds_Per_Splash = 3            # Number of seconds to spend per splash
  
  FadeIn_Seconds = 1                # Number of seconds to fade in a splash
  FadeOut_Seconds = 1               # Number of seconds to fade out a splash
  
  Window_Width = 544                # Pixel width of the window.
  Window_Height = 416               # Pixel height of the window.
  
  Allow_Skip = true                 # Allow Splashes to be skipped via input
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    # The current index we are at in our splash array.
    @splash_index = 0
    @cycle = 0
    @timer = 0
    
    # Figure out the time in terms of frames.
    @frames_per_fadein = FadeIn_Seconds * Graphics.frame_rate
    @frames_per_screen = Seconds_Per_Splash * Graphics.frame_rate
    @frames_per_fadeout = FadeOut_Seconds * Graphics.frame_rate
    
    # Gather the names of the images that will be the splash screens.
    @splash_screens = Dir[Splash_Dir + Splash_Image_Prefix + '*.*']
    for i in 0...@splash_screens.size
      @splash_screens[i] = @splash_screens[i].split('/').last.split('.')[0]
    end
    @splash_screens.sort!
    
    # Create our sprite.
    @splash_sprite = Sprite.new
    @splash_sprite.bitmap = Bitmap.new(Window_Width, Window_Height)
    @splash_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If the image needs to be drawn.
    if @old_splash_index != @splash_index
      @old_splash_index = @splash_index
      splash = Bitmap.new(Splash_Dir + @splash_screens[@splash_index])
      rect_x = (Window_Width >> 1) - (splash.width >> 1)
      rect_y = (Window_Height >> 1) - (splash.height >> 1)
      draw_x = rect_x >= 0 ? rect_x : 0
      draw_y = rect_y >= 0 ? rect_y : 0
      splash_rect = Rect.new(0, 0, splash.width, splash.height)
      @splash_sprite.bitmap.clear
      @splash_sprite.bitmap.blt(draw_x, draw_y, splash, splash_rect)
    end
    
    @timer += 1
    
    case @cycle
    when 0
      @splash_sprite.opacity += (255 / @frames_per_fadein)
      if @timer > @frames_per_fadein
        @timer = 0
        @cycle = 1
      end
    when 1
      if @timer > @frames_per_screen
        @timer = 0
        @cycle = 2
      end
    when 2
      @splash_sprite.opacity -= (255 / @frames_per_fadein)
      if @timer > @frames_per_fadeout
        @timer = 0
        @cycle = 0
        @splash_index += 1
      end
    end
    
    $scene = Scene_Title.new if @splash_index == @splash_screens.size
    $scene = Scene_Title.new if Input.trigger?(Input::B) && Allow_Skip
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @splash_sprite.bitmap.dispose unless @splash_sprite.bitmap.disposed?
    @splash_sprite.dispose unless @splash_sprite.disposed?
  end
end
I think I met all the requirements. Images can be prefixed 'Splash' with a number trailing. The number trailing tells the order that the splash will appear in. 'Splash000' comes before 'Splash001' for example. This is done for you automatically. No need to fill in an array or hash with your splash screen names. Splash screens are automatically centered on screen if they are smaller than the screen. If the splash is larger I take the center of the image. The splash images fade in and out over a period of second(s) which are defined in the constants. These constants can of course be changed to better suit your needs. If you have any questions on it let me know.

There is one final detail. We must make a change to the code in "Main". Replace it with:
Code:
#==============================================================================
# ** Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

begin
  Graphics.freeze
  $scene = Scene_Splash.new
  $scene.main while $scene != nil
  Graphics.transition(30)
rescue Errno::ENOENT
  filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")
end
I only changed the line that sets the initial Scene to our new Scene_Splash instead of Scene_Title.

As always good luck with it Reliez! :thumb:

[edit]
My pleasure.
 

Reliez

Member

khmp":2u2wxd6m said:
Code:
#==============================================================================
# ** Scene_Splash
#------------------------------------------------------------------------------
#  This class performs the splash screen processing.
#==============================================================================

class Scene_Splash < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Splash_Image_Prefix = 'Splash'    # Splash Images begin with what string
  Splash_Dir = 'Graphics/Pictures/' # Directory where the splash images are
  Seconds_Per_Splash = 3            # Number of seconds to spend per splash
  
  FadeIn_Seconds = 1                # Number of seconds to fade in a splash
  FadeOut_Seconds = 1               # Number of seconds to fade out a splash
  
  Window_Width = 544                # Pixel width of the window.
  Window_Height = 416               # Pixel height of the window.
  
  Allow_Skip = true                 # Allow Splashes to be skipped via input
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    # The current index we are at in our splash array.
    @splash_index = 0
    @cycle = 0
    @timer = 0
    
    # Figure out the time in terms of frames.
    @frames_per_fadein = FadeIn_Seconds * Graphics.frame_rate
    @frames_per_screen = Seconds_Per_Splash * Graphics.frame_rate
    @frames_per_fadeout = FadeOut_Seconds * Graphics.frame_rate
    
    # Gather the names of the images that will be the splash screens.
    @splash_screens = Dir[Splash_Dir + Splash_Image_Prefix + '*.*']
    for i in 0...@splash_screens.size
      @splash_screens[i] = @splash_screens[i].split('/').last.split('.')[0]
    end
    @splash_screens.sort!
    
    # Create our sprite.
    @splash_sprite = Sprite.new
    @splash_sprite.bitmap = Bitmap.new(Window_Width, Window_Height)
    @splash_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If the image needs to be drawn.
    if @old_splash_index != @splash_index
      @old_splash_index = @splash_index
      splash = Bitmap.new(Splash_Dir + @splash_screens[@splash_index])
      rect_x = (Window_Width >> 1) - (splash.width >> 1)
      rect_y = (Window_Height >> 1) - (splash.height >> 1)
      draw_x = rect_x >= 0 ? rect_x : 0
      draw_y = rect_y >= 0 ? rect_y : 0
      splash_rect = Rect.new(0, 0, splash.width, splash.height)
      @splash_sprite.bitmap.clear
      @splash_sprite.bitmap.blt(draw_x, draw_y, splash, splash_rect)
    end
    
    @timer += 1
    
    case @cycle
    when 0
      @splash_sprite.opacity += (255 / @frames_per_fadein)
      if @timer > @frames_per_fadein
        @timer = 0
        @cycle = 1
      end
    when 1
      if @timer > @frames_per_screen
        @timer = 0
        @cycle = 2
      end
    when 2
      @splash_sprite.opacity -= (255 / @frames_per_fadein)
      if @timer > @frames_per_fadeout
        @timer = 0
        @cycle = 0
        @splash_index += 1
      end
    end
    
    $scene = Scene_Title.new if @splash_index == @splash_screens.size
    $scene = Scene_Title.new if Input.trigger?(Input::B) && Allow_Skip
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @splash_sprite.bitmap.dispose unless @splash_sprite.bitmap.disposed?
    @splash_sprite.dispose unless @splash_sprite.disposed?
  end
end
I think I met all the requirements. Images can be prefixed 'Splash' with a number trailing. The number trailing tells the order that the splash will appear in. 'Splash000' comes before 'Splash001' for example. This is done for you automatically. No need to fill in an array or hash with your splash screen names. Splash screens are automatically centered on screen if they are smaller than the screen. If the splash is larger I take the center of the image. The splash images fade in and out over a period of second(s) which are defined in the constants. These constants can of course be changed to better suit your needs. If you have any questions on it let me know.

There is one final detail. We must make a change to the code in "Main". Replace it with:
Code:
#==============================================================================
# ** Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

begin
  Graphics.freeze
  $scene = Scene_Splash.new
  $scene.main while $scene != nil
  Graphics.transition(30)
rescue Errno::ENOENT
  filename = $!.message.sub("No such file or directory - ", "")
  print("Unable to find file #{filename}.")
end
I only changed the line that sets the initial Scene to our new Scene_Splash instead of Scene_Title.

As always good luck with it Reliez! :thumb:
Wow, thank you so much! :D
This is exactly what I needed. :]
Once again, thank you so much for you generosity!

At the cost of sounding too bothersome, is there a way to play a little background music for each splash screen?
Sorry, if it's to much trouble . . .
 

khmp

Sponsor

For each screen? Or throughout the whole scene? Here's the code for the whole scene:
Code:
#==============================================================================
# ** Scene_Splash
#------------------------------------------------------------------------------
#  This class performs the splash screen processing.
#==============================================================================

class Scene_Splash < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Splash_Image_Prefix = 'Splash'    # Splash Images begin with what string
  Splash_Dir = 'Graphics/Pictures/' # Directory where the splash images are
  Seconds_Per_Splash = 3            # Number of seconds to spend per splash
  
  FadeIn_Seconds = 1                # Number of seconds to fade in a splash
  FadeOut_Seconds = 1               # Number of seconds to fade out a splash
  
  Window_Width = 544                # Pixel width of the window.
  Window_Height = 416               # Pixel height of the window.
  
  Allow_Skip = true                 # Allow Splashes to be skipped via input
  
  Splash_BGM = 'Airship'            # Title of the BGM to play.
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    # The current index we are at in our splash array.
    @splash_index = 0
    @cycle = 0
    @timer = 0
    
    # Figure out the time in terms of frames.
    @frames_per_fadein = FadeIn_Seconds * Graphics.frame_rate
    @frames_per_screen = Seconds_Per_Splash * Graphics.frame_rate
    @frames_per_fadeout = FadeOut_Seconds * Graphics.frame_rate
    
    # Gather the names of the images that will be the splash screens.
    @splash_screens = Dir[Splash_Dir + Splash_Image_Prefix + '*.*']
    for i in 0...@splash_screens.size
      @splash_screens[i] = @splash_screens[i].split('/').last.split('.')[0]
    end
    @splash_screens.sort!
    
    $scene = Scene_Title.new if @splash_screens.empty?
    
    RPG::BGM.new(Splash_BGM, 100, 100).play
    
    # Create our sprite.
    @splash_sprite = Sprite.new
    @splash_sprite.bitmap = Bitmap.new(Window_Width, Window_Height)
    @splash_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    return if @splash_screens.empty?
    
    # If the image needs to be drawn.
    if @old_splash_index != @splash_index && !@splash_screens.empty?
      @old_splash_index = @splash_index
      splash = Bitmap.new(Splash_Dir + @splash_screens[@splash_index])
      rect_x = (Window_Width >> 1) - (splash.width >> 1)
      rect_y = (Window_Height >> 1) - (splash.height >> 1)
      draw_x = rect_x >= 0 ? rect_x : 0
      draw_y = rect_y >= 0 ? rect_y : 0
      splash_rect = Rect.new(0, 0, splash.width, splash.height)
      @splash_sprite.bitmap.clear
      @splash_sprite.bitmap.blt(draw_x, draw_y, splash, splash_rect)
    end
    
    @timer += 1
    
    case @cycle
    when 0
      @splash_sprite.opacity += (255 / @frames_per_fadein)
      if @timer > @frames_per_fadein
        @timer = 0
        @cycle = 1
      end
    when 1
      if @timer > @frames_per_screen
        @timer = 0
        @cycle = 2
      end
    when 2
      @splash_sprite.opacity -= (255 / @frames_per_fadein)
      if @timer > @frames_per_fadeout
        @timer = 0
        @cycle = 0
        @splash_index += 1
      end
    end
    
    $scene = Scene_Title.new if @splash_index == @splash_screens.size
    $scene = Scene_Title.new if Input.trigger?(Input::B) && Allow_Skip
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @splash_sprite.bitmap.dispose unless @splash_sprite.bitmap.disposed?
    @splash_sprite.dispose unless @splash_sprite.disposed?
    RPG::BGM.stop
  end
end

And here's if you wanted each splash to have a BGM. Just make sure the BGM has the same name as the splash screen. Its not required that every splash have a BGM. So it won't crash if you only have one splash with music or even no music.
Code:
#==============================================================================
# ** Scene_Splash
#------------------------------------------------------------------------------
#  This class performs the splash screen processing.
#==============================================================================

class Scene_Splash < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Splash_Image_Prefix = 'Splash'    # Splash Images begin with what string
  Splash_Dir = 'Graphics/Pictures/' # Directory where the splash images are
  Seconds_Per_Splash = 3            # Number of seconds to spend per splash
  
  FadeIn_Seconds = 1                # Number of seconds to fade in a splash
  FadeOut_Seconds = 1               # Number of seconds to fade out a splash
  
  Window_Width = 544                # Pixel width of the window.
  Window_Height = 416               # Pixel height of the window.
  
  Allow_Skip = true                 # Allow Splashes to be skipped via input
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    # The current index we are at in our splash array.
    @splash_index = 0
    @cycle = 0
    @timer = 0
    
    # Figure out the time in terms of frames.
    @frames_per_fadein = FadeIn_Seconds * Graphics.frame_rate
    @frames_per_screen = Seconds_Per_Splash * Graphics.frame_rate
    @frames_per_fadeout = FadeOut_Seconds * Graphics.frame_rate
    
    # Gather the names of the images that will be the splash screens.
    @splash_screens = Dir[Splash_Dir + Splash_Image_Prefix + '*.*']
    for i in 0...@splash_screens.size
      @splash_screens[i] = @splash_screens[i].split('/').last.split('.')[0]
    end
    @splash_screens.sort!
    
    $scene = Scene_Title.new if @splash_screens.empty?
    
    # Create our sprite.
    @splash_sprite = Sprite.new
    @splash_sprite.bitmap = Bitmap.new(Window_Width, Window_Height)
    @splash_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    return if @splash_screens.empty?
    
    # If the image needs to be drawn.
    if @old_splash_index != @splash_index && !@splash_screens.empty?
      @old_splash_index = @splash_index
      
      begin
        RPG::BGM.new(@splash_screens[@splash_index], 100, 100).play
      rescue
        
      end
      
      splash = Bitmap.new(Splash_Dir + @splash_screens[@splash_index])
      rect_x = (Window_Width >> 1) - (splash.width >> 1)
      rect_y = (Window_Height >> 1) - (splash.height >> 1)
      draw_x = [rect_x, 0].max
      draw_y = [rect_y, 0].max
      splash_rect = Rect.new(0, 0, splash.width, splash.height)
      @splash_sprite.bitmap.clear
      @splash_sprite.bitmap.blt(draw_x, draw_y, splash, splash_rect)
    end
    
    @timer += 1
    
    case @cycle
    when 0
      @splash_sprite.opacity += (255 / @frames_per_fadein)
      if @timer > @frames_per_fadein
        @timer = 0
        @cycle = 1
      end
    when 1
      if @timer > @frames_per_screen
        @timer = 0
        @cycle = 2
        Audio.bgm_fade(FadeOut_Seconds * 1000)
      end
    when 2
      @splash_sprite.opacity -= (255 / @frames_per_fadein)
      if @timer > @frames_per_fadeout
        @timer = 0
        @cycle = 0
        @splash_index += 1
      end
    end
    
    $scene = Scene_Title.new if @splash_index == @splash_screens.size
    $scene = Scene_Title.new if Input.trigger?(Input::B) && Allow_Skip
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @splash_sprite.bitmap.dispose unless @splash_sprite.bitmap.disposed?
    @splash_sprite.dispose unless @splash_sprite.disposed?
    RPG::BGM.stop
  end
end

Good luck with it Reliez! :thumb:
 

Reliez

Member

khmp":2ffofuu9 said:
For each screen? Or throughout the whole scene? Here's the code for the whole scene:
Code:
#==============================================================================
# ** Scene_Splash
#------------------------------------------------------------------------------
#  This class performs the splash screen processing.
#==============================================================================

class Scene_Splash < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Splash_Image_Prefix = 'Splash'    # Splash Images begin with what string
  Splash_Dir = 'Graphics/Pictures/' # Directory where the splash images are
  Seconds_Per_Splash = 3            # Number of seconds to spend per splash
  
  FadeIn_Seconds = 1                # Number of seconds to fade in a splash
  FadeOut_Seconds = 1               # Number of seconds to fade out a splash
  
  Window_Width = 544                # Pixel width of the window.
  Window_Height = 416               # Pixel height of the window.
  
  Allow_Skip = true                 # Allow Splashes to be skipped via input
  
  Splash_BGM = 'Airship'            # Title of the BGM to play.
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    # The current index we are at in our splash array.
    @splash_index = 0
    @cycle = 0
    @timer = 0
    
    # Figure out the time in terms of frames.
    @frames_per_fadein = FadeIn_Seconds * Graphics.frame_rate
    @frames_per_screen = Seconds_Per_Splash * Graphics.frame_rate
    @frames_per_fadeout = FadeOut_Seconds * Graphics.frame_rate
    
    # Gather the names of the images that will be the splash screens.
    @splash_screens = Dir[Splash_Dir + Splash_Image_Prefix + '*.*']
    for i in 0...@splash_screens.size
      @splash_screens[i] = @splash_screens[i].split('/').last.split('.')[0]
    end
    @splash_screens.sort!
    
    $scene = Scene_Title.new if @splash_screens.empty?
    
    RPG::BGM.new(Splash_BGM, 100, 100).play
    
    # Create our sprite.
    @splash_sprite = Sprite.new
    @splash_sprite.bitmap = Bitmap.new(Window_Width, Window_Height)
    @splash_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    return if @splash_screens.empty?
    
    # If the image needs to be drawn.
    if @old_splash_index != @splash_index && !@splash_screens.empty?
      @old_splash_index = @splash_index
      splash = Bitmap.new(Splash_Dir + @splash_screens[@splash_index])
      rect_x = (Window_Width >> 1) - (splash.width >> 1)
      rect_y = (Window_Height >> 1) - (splash.height >> 1)
      draw_x = rect_x >= 0 ? rect_x : 0
      draw_y = rect_y >= 0 ? rect_y : 0
      splash_rect = Rect.new(0, 0, splash.width, splash.height)
      @splash_sprite.bitmap.clear
      @splash_sprite.bitmap.blt(draw_x, draw_y, splash, splash_rect)
    end
    
    @timer += 1
    
    case @cycle
    when 0
      @splash_sprite.opacity += (255 / @frames_per_fadein)
      if @timer > @frames_per_fadein
        @timer = 0
        @cycle = 1
      end
    when 1
      if @timer > @frames_per_screen
        @timer = 0
        @cycle = 2
      end
    when 2
      @splash_sprite.opacity -= (255 / @frames_per_fadein)
      if @timer > @frames_per_fadeout
        @timer = 0
        @cycle = 0
        @splash_index += 1
      end
    end
    
    $scene = Scene_Title.new if @splash_index == @splash_screens.size
    $scene = Scene_Title.new if Input.trigger?(Input::B) && Allow_Skip
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @splash_sprite.bitmap.dispose unless @splash_sprite.bitmap.disposed?
    @splash_sprite.dispose unless @splash_sprite.disposed?
    RPG::BGM.stop
  end
end

Yeah, for each screen, just like a little jingle that plays for that slide. ^^;

Sorry for being so bothersome . . .
 

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