DizzyFoxkit

Scene_Title attraction

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