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.

Seph's Introduction & Splash System Question

dabum

Member

Code:
#==============================================================================
# ** Introduction & Splash System
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 4
# 2006-12-06
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 -------------------------------------------- (Aprrox. 2005-01-01)
#   Version 2 ---------------------------------------------------- (2005-01-08)
#    - Update : Re-scripted Much of the System
#   Version 3 ---------------------------------------------------- (2006-08-04)
#    - Update : Re-scripted Much of the System
#    Version 3.01 ------------------------------------------------ (2006-10-17)
#     - Bug Fix : Made Introduction Scene Child Class of Scene Base
#   Version 4 ---------------------------------------------------- (2006-12-06)
#    - Update : Re-scripted Much of the System Adding New Features
#------------------------------------------------------------------------------
# * Requirements :
#
#   Scene_Base
#------------------------------------------------------------------------------
# * Description :
#
#   This Script was designed to create an introduction before the title screen
#   in your game. You will also have the option to display a splash screen,
#   where an image will flash (Usually Press Start). It also adds a timer at
#   both the splash screen and in the title screen, so after X seconds, it
#   will replay the introduction and splash. The splash is completely
#   optional. You can "hold" images for a defined duration before the image
#   disappears as well.
#
#   You can now add skip function, that will allow you to skip the introduction
#   if: skip if first play, skip additional plays, skip if savefile is found.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Setup Introduction, refer to customization below.
#------------------------------------------------------------------------------
# * Customization :
#
#   Play in Debug Mode
#    - Play_Intro_In_Debug_Mode = true (ON) or false (OFF)
#
#   ** Skip Options **
#
#   Can Skip if Savefile Present
#    - Can_Skip_Savefile = true or false
#
#   Can Skip Intro If First Play
#    - Can_Skip_FirstPlay = true or false
#
#   Can Skip Intor If Additonal Play
#    - Can_Skip_AdditionalPlays = true or false
#
#   ** Intor Options **
#
#   Intorduction Pictures
#    - Intro_Pictures         = ['filename', ...]
#
#   Introduction Wait Counts
#    - Intro_WaitCounts       = [n, ...]
#
#   Splash Image
#    - Splash_Picture         = 'filename' or nil
#
#   Start Image
#    - Start_Picture          = 'filename'
#
#   Introduction Image Speed
#    - Intro_Speed            = n
#
#   Start Image Speed
#    - Start_Speed            = n
#
#   Seconds To Restart Introduction from Splash
#    - Splash_Restart_Seconds = n
#
#   Seconds To Restart Introduction from Title
#    - Title_Restart_Seconds  = n
#
#   Introduciton BGM
#    - Introduction_BGM       = RPG::AudioFile
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Introduction & Splash System', 'SephirothSpawn',4, '2006-12-06')

#------------------------------------------------------------------------------
# * Scene Base Test
#------------------------------------------------------------------------------
unless SDK.state('Scene Base')
  # Print Error
  p 'Scene Base Not Found. Introduction & Splash System Disabled.'
  # Disable Encounter Control
  SDK.disable('Introduction & Splash System')
end

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Introduction & Splash System')

#==============================================================================
# ** Play Introduction in Debug Mode
#==============================================================================

Play_Intro_In_Debug_Mode = false
  
#==============================================================================
# ** Scene_Introduction
#==============================================================================

class Scene_Introduction < Scene_Base
  #--------------------------------------------------------------------------
  # * Skip Intro Test
  #
  #   Can_Skip_Savefile = true or false
  #    - When Savefile is present
  #   Can_Skip_First_Play = true or false
  #    - When Game First Opening Intro
  #   Can_Skip_AdditionalPlays = true or false
  #    - When Returning From Title Screen (Replay)
  #--------------------------------------------------------------------------
  Can_Skip_Savefile = true
  Can_Skip_FirstPlay = false
  Can_Skip_AdditionalPlays = true
  #--------------------------------------------------------------------------
  # * Options
  #
  #  Intro_Pictures         = ['filename', ...]
  #  Intro_WaitCounts       = [n, ...]
  #  Splash_Picture         = 'filename' or nil
  #  Start_Picture          = 'filename'
  #  Intro_Speed            = n
  #  Start_Speed            = n
  #  Splash_Restart_Seconds = n
  #  Title_Restart_Seconds  = n
  #  Introduction_BGM       = RPG::AudioFile
  #--------------------------------------------------------------------------
  Intro_Pictures         = ['001-Title01', '001-Title01', '001-Title01']
  Intro_WaitCounts       = [40, 20, 10]
  Splash_Picture         = nil
  Start_Picture          = 'Press Start'
  Intro_Speed            = 5
  Start_Speed            = 5
  Splash_Restart_Seconds = 10
  Title_Restart_Seconds  = 15
  Introduction_BGM       = load_data('Data/System.rxdata').title_bgm
  #--------------------------------------------------------------------------
  # * Main Processing : Variable Initialization
  #--------------------------------------------------------------------------
  def main_variable
    # Sets Phase, Picture Index & Wait Count
    @index, @phase, @wait_count = 0, 0, 0
    # Sets Intro Pic Speed & Splash Pic Speed
    @sprite_speed, @start_speed = Intro_Speed, Start_Speed
    # Turns Extra Play off
    @extra_play = false
  end
  #--------------------------------------------------------------------------
  # * Main Processing : Sprite Initialization
  #--------------------------------------------------------------------------
  def main_sprite
    # Background Images
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title(Intro_Pictures[@index])
    @sprite.opacity = 0
    # Start Logo
    unless Splash_Picture.nil?
      @start = Sprite.new
      @start.bitmap = RPG::Cache.title(Start_Image)
      @start.x = 320 - @start.bitmap.width / 2
      @start.y = 480 - @start.bitmap.height - 32
      @start.z = 10
      @start.opacity = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Main Processing : Audio Initialization
  #--------------------------------------------------------------------------
  def main_audio
    # Play Introduction BGM
    Audio.bgm_play('Audio/BGM/' + Introduction_BGM.name)
  end
  #--------------------------------------------------------------------------
  # * Main Processing : Ending
  #--------------------------------------------------------------------------
  def main_end
    # Fade BGM
    Audio.bgm_fade(5)
    # If Premain
    $pre_main ? $pre_main = false : $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # * Can Skip?
  #--------------------------------------------------------------------------
  def can_skip?
    # If Savefile
    if Can_Skip_Savefile
      # Checks Each File
      for i in 0..3
        if FileTest.exist?("Save#{i+1}.rxdata")
          # Return True
          return true
        end
      end
    end
    # If First Play & Can Skip First Play
    if $pre_main && @extra_play == false
      # Return Can Skip First Play
      return Can_Skip_FirstPlay
    # If Title Play & Can Skip Title Plays
    else
      # Return Can Skip Additional Plays
      return Can_Skip_AdditionalPlays
    end
    # Return False
    return false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    case @phase
    when 0 # Introduction Procreesing
      update_intro
    when 1 # Splash Procreesing
      update_splash
    when 2 # Splash Transition
      to_splash_transition
    when 3 # Title Transition
      to_title_transition
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Intro Images
  #--------------------------------------------------------------------------
  def update_intro
    # If C is pressed
    if Input.trigger?(Input::C)
      # If Can Skip
      if can_skip?
        # Invert Speed
        @sprite_speed *= -1 if @sprite_speed > 0
        # Switch Phase
        @phase = Splash_Picture.nil? ? 3 : 2
        return
      end
    end
    # If Wait Count
    if @wait_count > 0
      # Decrease Wait Count
      @wait_count -= 1
      return
    end
    # Updates Sprite Opacity
    @sprite.opacity += @sprite_speed
    # Changes Direction & Sets Wait Count
    if @sprite.opacity >= 255
      @sprite_speed *= -1 if @sprite_speed > 0
      @wait_count = Intro_WaitCounts[@index]
      return
    end
    # Change Sprite
    if @sprite.opacity <= 0
      # Increase Index & Inverts Intro Speed
      @index += 1 ; @sprite_speed *= -1
      # Switches Phase If Last Picture or Changes Intro Picure
      @index == Intro_Pictures.size ? @phase = Splash_Picture.nil? ? 3 : 2 :
        @sprite.bitmap = RPG::Cache.title(Intro_Pictures[@index])
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Splash Image
  #--------------------------------------------------------------------------
  def update_splash
    # If Restart on splash and seconds reached
    unless Splash_Restart_Seconds.nil?
      if Graphics.frame_count % 
         (Graphics.frame_rate * Seconds_Until_Restart) == 0
        # Restart Scene
        $scene = self.new
        # Turns Extra Play On
        @extra_play = true
        return
      end
    end
    # If C is pressed
    if Input.trigger?(Input::C)
      # Make Intro Speed Negative
      @sprite_speed *= -1 if @sprite_speed > 0
      # Make Splash Speed Negative
      @start_speed *= -1 if @start_speed > 0
      # Switches To Title Phase
      @phase = 3
      return
    end
    # Loads Sprite Splash Bitmap
    @sprite.bitmap = RPG::Cache.title(Splash_Picture)
    # Updates Sprite Opacity
    @sprite.opacity += @sprite_speed
    # Updates Start Logo Opacity
    @start.opacity += @start_speed
    # Changes Direction
    @start_speed *= -1 if @start.opacity >= 255 || @start.opacity <= 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Intro To Splash Transistion
  #--------------------------------------------------------------------------
  def to_splash_transition
    # Make Sprite Speed Negitve (If Not)
    @sprite_speed *= -1 if @sprite_speed > 0
    # Decrease Intro Pic Opacity
    if @sprite.opacity > 0
      @sprite.opacity += @sprite_speed
      return
    end
    # Switch Phase
    @phase = 1
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Splash To Title Transistion
  #--------------------------------------------------------------------------
  def to_title_transition
    # Make Sprite Speed Negitve (If Not)
    @sprite_speed *= -1 if @sprite_speed > 0
    @start_speed  *= -1 if @start_speed  > 0
    # Decrease Intro Pic Opacity
    if @sprite.opacity > 0
      @sprite.opacity += @sprite_speed
    end
    # Updates Splash Opacity
    unless @start.nil?
      if @start.opacity > 0
        @start.opacity += @start_speed
      end
    end
    # Stop If Opacities Not 0
    if @sprite.opacity > 0 || ( (not @start.nil?) && @start.opacity )
      return
    end
    # End Introduction
    $scene = nil
    # Restart Graphics Frame Count
    Graphics.frame_count = 0
  end
end
 
#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_intro_scnttl_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If Play in Debug or Not In Debug Mode
    if Play_Intro_In_Debug_Mode || (not $DEBUG)
      # If Restart && Seconds Reached
      unless (secs = Scene_Introduction::Title_Restart_Seconds).nil?
        if Graphics.frame_count % (Graphics.frame_rate * secs) == 0
          # Switch to Splash Scene
          $scene = Scene_Introduction.new
        end
      end
    end
    # Original Update
    seph_intro_scnttl_update
  end
end

#==============================================================================
# ** Pre-Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

# If Play in Debug or Not In Debug Mode
if Play_Intro_In_Debug_Mode || (not $DEBUG)
  begin 
    # Sets Pre-main flag
    $pre_main = true
    # Prepare for transition
    Graphics.freeze
    # Proceed to Introduction & Splash Scene
    $scene = Scene_Introduction.new
    # Call main method as long as $scene is effective
    while $scene != nil
      $scene.main
    end
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

I believe that this is the latest version for Sephs' Introduction & Splash system.
However I was wondering if there was a way to eliminate the fade on certain intervals.
Any help would be appreciated.
 

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