ThePageMaster

WynEngine Splash Scene

Mar 17th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.84 KB | None | 0 0
  1. #===============================================================================
  2. # Author: Wyn Wizard
  3. # Supporting Authors: Dekita
  4. # Title: Wyn Engine Ace - Splash Scene
  5. # Creation Date: 2/16/2017
  6. # Version: 1.0
  7. #===============================================================================
  8. # KNOWN BUGS:
  9. # None
  10. #-------------------------------------------------------------------------------
  11. # WARNING:
  12. # This script does alias and overwrite some parts of the Scene_Title. Please be
  13. # aware that this can, and probably will, cause a conflict with any other
  14. # scripts that also change Scene_Title. Please use at your own caution.
  15. #-------------------------------------------------------------------------------
  16. # UPDATES:
  17. # 1.) Made this one stand alone. Core script no longer needed.
  18. #-------------------------------------------------------------------------------
  19. # INSTRUCTIONS:
  20. # 1.) This script must be placed below the DMEA Core Script in order for it to
  21. #     run properly.
  22. # 2.) This script is fairy flexible, and the editable region is fairly easy to
  23. #     follow.
  24. #     The Scenes array is broken into a set of hashs that incude:
  25. #     name of the picture file wanted to be shown, picture's "hang" on
  26. #     the screen, and then its fade speeds. You can create more than one scene.
  27. #     To do this, go to the last scene in the Splash_Settings module and add a
  28. #     "," to it. Then insert this into a new line:
  29. #     {:name => "file_name, :hang => frames, :fade => [fade_in, fade_out]}
  30. #       - The file name is the name of the picture
  31. #       - The frames tells the scene how long to hold the picture on the scene
  32. #         [60 frames = 1 sec]
  33. #       - The fade in speed controls the oppacity of the picture's incremement
  34. #         speed which makes the picture appear on the screen.
  35. #       - The fade out speed controls the oppacity of the picture's decremement
  36. #         speed which makes the picture disappear from the screen
  37. #
  38. # If any errors occur, please feel free to email me at [email protected],
  39. # or pm me, Wyn Wizard.
  40. #-------------------------------------------------------------------------------
  41. # TERMS AND CONDITIONS:
  42. # 1.) You must credit Wyn Wizard and Dekita if you use this script or this
  43. #     engine.
  44. # 2.) This script and engine is free for non comercial games.
  45. # 3.) This script and engine is not free for commercial games. If you want to
  46. #     use this engine in a comercial game, pm me since i am the main code
  47. #     master.
  48. # 4.) Do not claim this script as your own. I know my coding style, and I will
  49. #     persue legal actions.
  50. #===============================================================================
  51. # Version: At the moment, this is not needed. May be needed in future releases.
  52. ($imported||={})[:Wyn_Splash] = 1.1
  53. #===============================================================================
  54. # ■ EDITABLE REGION
  55. #===============================================================================
  56. module WEA
  57.   module Splash_Settings
  58.     Scenes = [
  59.       # [name of picture, how long the picture stays]
  60.       {:name => "studio_logo", :hang => 60},
  61.       #{:name => "dekita_studio_logo", :hang => 60}
  62.     ]
  63.     Fade_in_speed = 2
  64.     Fade_out_speed = 4
  65.     Sounds = {
  66.       :title      => ["Audio/BGM/" + "Theme5", 80, 100]
  67.     }
  68.     #---------------------------------------------------------------------------
  69.     # ■ Play BGM
  70.     #---------------------------------------------------------------------------
  71.     def self.play_bgm(key)
  72.       Audio.bgm_play(*Sounds[key])
  73.     end
  74.   end
  75. end
  76. #===============================================================================
  77. # DO NOT EDIT BELOW HERE!
  78. # EDITING BELOW HERE MAY RESULT IN, BUT NOT RESTRICTED TO: NAUSEA, VOMITING,
  79. # EXPLOSIVE DIARRHEA, IMPLOSIVE DIARRHEA, DEMINSIA, LOSS OF: VISION, HEARING,
  80. # FEELING IN YOUR LEFT LEG, OR HAIR.
  81. #===============================================================================
  82. # ** SceneManager
  83. #-----------------------------------------------------------------------------
  84. #  This module manages scene transitions. For example, it can handle
  85. # hierarchical structures such as calling the item screen from the main menu
  86. # or returning from the item screen to the main menu.
  87. #------------------------------------------------------------------------------
  88. # Functions Overwritten: 1
  89. # Functions Aliased: 0
  90. #=============================================================================
  91. class << SceneManager
  92.   #---------------------------------------------------------------------------
  93.   # * Get First Scene Class
  94.   #---------------------------------------------------------------------------
  95.   def first_scene_class
  96.     $BTEST ? Scene_Battle : Scene_Splash
  97.   end
  98. end
  99. #=============================================================================
  100. # ** Splash Scene
  101. #-----------------------------------------------------------------------------
  102. #  This class holds the fucntionality that runs the splash scene before the
  103. #   screen runs.
  104. #=============================================================================
  105. class Scene_Splash < Scene_Base
  106.   #---------------------------------------------------------------------------
  107.   # ■ Start Method
  108.   #---------------------------------------------------------------------------
  109.   def start
  110.     super
  111. #   WEA::Splash_Settings::play_bgm(:title)
  112.     @sprite = Sprite.new(@viewport)
  113.     @splash_scenes = WEA::Splash_Settings::Scenes.compact()
  114.     @splash_scene_id = 0
  115.     @fade_in_speed = WEA::Splash_Settings::Fade_in_speed
  116.     @fade_out_speed = WEA::Splash_Settings::Fade_out_speed
  117.     reset_splash()
  118.   end
  119.   #---------------------------------------------------------------------------
  120.   # ■ Reset Splash Scene Method
  121.   #---------------------------------------------------------------------------    
  122.   def reset_splash
  123.     data = @splash_scenes[@splash_scene_id]
  124.     return unless data
  125.     @stage = :fade_in
  126.     @stage_opacity = 0
  127.     @mid_hang = data[:hang]
  128.     @sprite.bitmap = Cache.picture(data[:name])
  129.     @sprite.opacity = @stage_opacity
  130.     @sprite_center_x = Graphics.width/2 - (@sprite.width/2)
  131.     @sprite_center_y = Graphics.height/2 - (@sprite.height/2)
  132.     @sprite.x = @sprite_center_x
  133.     @sprite.y = @sprite_center_y
  134.     @sprite.zoom_x = (@sprite.zoom_y = 1.0)
  135.   end
  136.   #---------------------------------------------------------------------------
  137.   # ■ Update Method
  138.   #---------------------------------------------------------------------------    
  139.   def update
  140.     super
  141.     case @stage
  142.       when :fade_in  then @stage_opacity += @fade_in_speed
  143.         @stage = :fade_mid if @stage_opacity >= 255
  144.       when :fade_mid  then @mid_hang -= 1
  145.         @stage = :fade_out if @mid_hang <= 0
  146.       when :fade_out then @stage_opacity -= @fade_out_speed
  147.         @sprite.zoom_x = (@sprite.zoom_y -= 0.001)
  148.         @sprite_center_x = Graphics.width/2 - ((@sprite.width * @sprite.zoom_x)/2)
  149.         @sprite_center_y = Graphics.height/2 - ((@sprite.height * @sprite.zoom_y)/2)
  150.         @sprite.x = @sprite_center_x
  151.         @sprite.y = @sprite_center_y
  152.         @stage = :end if @stage_opacity <= 0
  153.       when :end then update_stage_id()
  154.     end
  155.     @sprite.opacity = @stage_opacity
  156.   end
  157.   #---------------------------------------------------------------------------
  158.   # ■ Update Stage ID Method
  159.   #---------------------------------------------------------------------------    
  160.   def update_stage_id
  161.     if (@splash_scene_id == @splash_scenes.size())
  162.       SceneManager.call(Scene_Title)
  163.     else
  164.       @splash_scene_id += 1
  165.       reset_splash()
  166.     end
  167.   end
  168. end
  169. #==============================================================================
  170. # ** Scene_Title
  171. #------------------------------------------------------------------------------
  172. #  This class performs the title screen processing.
  173. #------------------------------------------------------------------------------
  174. # Functions Overwritten: 1
  175. # Functions Aliased: 14
  176. #==============================================================================
  177. class Scene_Title < Scene_Base
  178.   #--------------------------------------------------------------------------
  179.   # * Start Processing
  180.   #--------------------------------------------------------------------------
  181.   alias :wea_splash_title_start start
  182.   def start
  183.     wea_splash_title_start()
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # * Get Transition Speed
  187.   #--------------------------------------------------------------------------
  188.   alias :wea_splash_title_speed transition_speed
  189.   def transition_speed
  190.     wea_splash_title_speed()
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Termination Processing
  194.   #--------------------------------------------------------------------------
  195.   alias :wea_splash_title_terminate terminate
  196.   def terminate
  197.     wea_splash_title_terminate()
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # * Create Background
  201.   #--------------------------------------------------------------------------
  202.   alias :wea_splash_title_createBackground create_background
  203.   def create_background
  204.     wea_splash_title_createBackground()
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # * Create Foreground
  208.   #--------------------------------------------------------------------------
  209.   alias :wea_splash_title_createForeground create_foreground
  210.   def create_foreground
  211.     wea_splash_title_createForeground()
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * Draw Game Title
  215.   #--------------------------------------------------------------------------
  216.   alias :wea_splash_title_drawGameTitle draw_game_title
  217.   def draw_game_title
  218.     wea_splash_title_drawGameTitle
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # * Free Background
  222.   #--------------------------------------------------------------------------
  223.   alias :wea_splash_title_disposeBackground dispose_background
  224.   def dispose_background
  225.     wea_splash_title_disposeBackground()
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # * Free Foreground
  229.   #--------------------------------------------------------------------------
  230.   alias :wea_splash_title_disposeForeground dispose_foreground
  231.   def dispose_foreground
  232.     wea_splash_title_disposeForeground()
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # * Move Sprite to Screen Center
  236.   #--------------------------------------------------------------------------
  237.   alias :wea_splash_title_centerSprite center_sprite
  238.   def center_sprite(sprite)
  239.     wea_splash_title_centerSprite(sprite)
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # * Create Command Window
  243.   #--------------------------------------------------------------------------
  244.   alias :wea_splash_title_createCMDWin create_command_window
  245.   def create_command_window
  246.     wea_splash_title_createCMDWin()
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Close Command Window
  250.   #--------------------------------------------------------------------------
  251.   alias :wea_splash_title_closeCMDWin close_command_window
  252.   def close_command_window
  253.     wea_splash_title_closeCMDWin()
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * [New Game] Command
  257.   #--------------------------------------------------------------------------
  258.   alias :wea_splash_title_newGameCMD command_new_game
  259.   def command_new_game
  260.     wea_splash_title_newGameCMD()
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * [Continue] Command
  264.   #--------------------------------------------------------------------------
  265.   alias :wea_splash_title_continueCMD command_continue
  266.   def command_continue
  267.     wea_splash_title_continueCMD()
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # * [Shut Down] Command
  271.   #--------------------------------------------------------------------------
  272.   alias :wea_splash_title_shutdownCMD command_shutdown
  273.   def command_shutdown
  274.     wea_splash_title_shutdownCMD()
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # * Play Title Screen Music
  278.   #--------------------------------------------------------------------------
  279.   def play_title_music
  280.     # Overwritten method to allow the music from the splash screen to continue.
  281.   end
  282. end #end script
  283. #==============================================================================#
  284. # ** Script created by Wyn Wizard **                                           #
  285. #==============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment