Advertisement
DizzyFoxkit

Custom Scene Title

Jan 27th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.05 KB | None | 0 0
  1. #==============================================================================
  2. # ** Scene_Title
  3. #------------------------------------------------------------------------------
  4. #  This class performs title screen processing.
  5. #==============================================================================
  6.  
  7. class Scene_Title
  8.   #--------------------------------------------------------------------------
  9.   # * Main Processing
  10.   #--------------------------------------------------------------------------
  11.   def main
  12.     # If battle test
  13.     if $BTEST
  14.       battle_test
  15.       return
  16.     end
  17.     # Load database
  18.     $data_actors        = load_data("Data/Actors.rxdata")
  19.     $data_classes       = load_data("Data/Classes.rxdata")
  20.     $data_skills        = load_data("Data/Skills.rxdata")
  21.     $data_items         = load_data("Data/Items.rxdata")
  22.     $data_weapons       = load_data("Data/Weapons.rxdata")
  23.     $data_b_weapons     = load_data("Data/B_Weapons.rxdata")
  24.     $data_armors        = load_data("Data/Armors.rxdata")
  25.     $data_enemies       = load_data("Data/Enemies.rxdata")
  26.     $data_troops        = load_data("Data/Troops.rxdata")
  27.     $data_states        = load_data("Data/States.rxdata")
  28.     $data_animations    = load_data("Data/Animations.rxdata")
  29.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  30.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  31.     $data_system        = load_data("Data/System.rxdata")
  32.     # Make system object
  33.     $game_system = Game_System.new
  34.     # Make title graphic
  35.     @sprite = Sprite.new
  36.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  37.     # Make command window
  38.     s1 = "New Game"
  39.     s2 = "Continue"
  40.     s3 = "Shutdown"
  41.     @command_window = Window_Command.new(192, [s1, s2, s3])
  42.     @command_window.back_opacity = 160
  43.     @command_window.x = 320 - @command_window.width / 2
  44.     @command_window.y = 288
  45.     # Continue enabled determinant
  46.     # Check if at least one save file exists
  47.     # If enabled, make @continue_enabled true; if disabled, make it false
  48.     @continue_enabled = false
  49.     for i in 0..3
  50.       if FileTest.exist?("Save#{i+1}.rxdata")
  51.         @continue_enabled = true
  52.       end
  53.     end
  54.     # If continue is enabled, move cursor to "Continue"
  55.     # If disabled, display "Continue" text in gray
  56.     if @continue_enabled
  57.       @command_window.index = 1
  58.     else
  59.       @command_window.disable_item(1)
  60.     end
  61.     # Play title BGM
  62.     $game_system.bgm_play($data_system.title_bgm)
  63.     # Stop playing ME and BGS
  64.     Audio.me_stop
  65.     Audio.bgs_stop
  66.     # Execute transition
  67.     Graphics.transition
  68.     # Main loop
  69.     loop do
  70.       # Update game screen
  71.       Graphics.update
  72.       # Update input information
  73.       Input.update
  74.       # Frame update
  75.       update
  76.       # Abort loop if screen is changed
  77.       if $scene != self
  78.         break
  79.       end
  80.     end
  81.     # Prepare for transition
  82.     Graphics.freeze
  83.     # Dispose of command window
  84.     @command_window.dispose
  85.     # Dispose of title graphic
  86.     @sprite.bitmap.dispose
  87.     @sprite.dispose
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Frame Update
  91.   #--------------------------------------------------------------------------
  92.   def update
  93.     # Update command window
  94.     @command_window.update
  95.     # If C button was pressed
  96.     if Input.trigger?(Input::C)
  97.       # Branch by command window cursor position
  98.       case @command_window.index
  99.       when 0  # New game
  100.         command_new_game
  101.       when 1  # Continue
  102.         command_continue
  103.       when 2  # Shutdown
  104.         command_shutdown
  105.       end
  106.     end
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Command: New Game
  110.   #--------------------------------------------------------------------------
  111.   def command_new_game
  112.     # Play decision SE
  113.     $game_system.se_play($data_system.decision_se)
  114.     # Stop BGM
  115.     Audio.bgm_stop
  116.     # Reset frame count for measuring play time
  117.     Graphics.frame_count = 0
  118.     # Make each type of game object
  119.     $game_temp          = Game_Temp.new
  120.     $game_system        = Game_System.new
  121.     $game_switches      = Game_Switches.new
  122.     $game_variables     = Game_Variables.new
  123.     $game_self_switches = Game_SelfSwitches.new
  124.     $game_screen        = Game_Screen.new
  125.     $game_actors        = Game_Actors.new
  126.     $game_party         = Game_Party.new
  127.     $game_troop         = Game_Troop.new
  128.     $game_map           = Game_Map.new
  129.     $game_player        = Game_Player.new
  130.     # Set up initial party
  131.     $game_party.setup_starting_members
  132.     # Set up initial map position
  133.     $game_map.setup($data_system.start_map_id)
  134.     # Move player to initial position
  135.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  136.     # Refresh player
  137.     $game_player.refresh
  138.     # Run automatic change for BGM and BGS set with map
  139.     $game_map.autoplay
  140.     # Update map (run parallel process event)
  141.     $game_map.update
  142.     # Switch to map screen
  143.     $scene = Scene_Map.new
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # * Command: Continue
  147.   #--------------------------------------------------------------------------
  148.   def command_continue
  149.     # If continue is disabled
  150.     unless @continue_enabled
  151.       # Play buzzer SE
  152.       $game_system.se_play($data_system.buzzer_se)
  153.       return
  154.     end
  155.     # Play decision SE
  156.     $game_system.se_play($data_system.decision_se)
  157.     # Switch to load screen
  158.     $scene = Scene_Load.new
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Command: Shutdown
  162.   #--------------------------------------------------------------------------
  163.   def command_shutdown
  164.     # Play decision SE
  165.     $game_system.se_play($data_system.decision_se)
  166.     # Fade out BGM, BGS, and ME
  167.     Audio.bgm_fade(800)
  168.     Audio.bgs_fade(800)
  169.     Audio.me_fade(800)
  170.     # Shutdown
  171.     $scene = nil
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Battle Test
  175.   #--------------------------------------------------------------------------
  176.   def battle_test
  177.     # Load database (for battle test)
  178.     $data_actors        = load_data("Data/BT_Actors.rxdata")
  179.     $data_classes       = load_data("Data/BT_Classes.rxdata")
  180.     $data_skills        = load_data("Data/BT_Skills.rxdata")
  181.     $data_items         = load_data("Data/BT_Items.rxdata")
  182.     $data_weapons       = load_data("Data/BT_Weapons.rxdata")
  183.     $data_armors        = load_data("Data/BT_Armors.rxdata")
  184.     $data_enemies       = load_data("Data/BT_Enemies.rxdata")
  185.     $data_troops        = load_data("Data/BT_Troops.rxdata")
  186.     $data_states        = load_data("Data/BT_States.rxdata")
  187.     $data_animations    = load_data("Data/BT_Animations.rxdata")
  188.     $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
  189.     $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
  190.     $data_system        = load_data("Data/BT_System.rxdata")
  191.     # Reset frame count for measuring play time
  192.     Graphics.frame_count = 0
  193.     # Make each game object
  194.     $game_temp          = Game_Temp.new
  195.     $game_system        = Game_System.new
  196.     $game_switches      = Game_Switches.new
  197.     $game_variables     = Game_Variables.new
  198.     $game_self_switches = Game_SelfSwitches.new
  199.     $game_screen        = Game_Screen.new
  200.     $game_actors        = Game_Actors.new
  201.     $game_party         = Game_Party.new
  202.     $game_troop         = Game_Troop.new
  203.     $game_map           = Game_Map.new
  204.     $game_player        = Game_Player.new
  205.     # Set up party for battle test
  206.     $game_party.setup_battle_test_members
  207.     # Set troop ID, can escape flag, and battleback
  208.     $game_temp.battle_troop_id = $data_system.test_troop_id
  209.     $game_temp.battle_can_escape = true
  210.     $game_map.battleback_name = $data_system.battleback_name
  211.     # Play battle start SE
  212.     $game_system.se_play($data_system.battle_start_se)
  213.     # Play battle BGM
  214.     $game_system.bgm_play($game_system.battle_bgm)
  215.     # Switch to battle screen
  216.     $scene = Scene_Battle.new
  217.   end
  218. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement