Advertisement
KingGerar

Dragon Scene Title

Oct 1st, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.52 KB | None | 0 0
  1. #===============================================================================
  2. # Dragon Scene Title
  3. # Autor: King Gerar
  4. #-------------------------------------------------------------------------------
  5. # Tela de título (Scene_Title) modificada, com a função "Press Start" e uma
  6. # barrinha de "Loading". Todas as animações são compostas por imagens, portanto
  7. # fique atento.
  8. #===============================================================================
  9. # O módulo Title_Images guarda as imagens que serão usadas no Scene Title.
  10. # Essas imagens devem estar na pasta Graphics/System de seu projeto.
  11. #===============================================================================
  12.  
  13. module Title_Images
  14.   TitleBackground = "Title-Background"
  15.   TitleName = "Title-NameTitle"
  16.   TitlePressStart = "Title-PressStart"
  17.   TitleNewGame = "Title-NewGame"
  18.   TitleContinue = "Title-Continue"
  19.   TitleQuit = "Title-Quit"
  20.   TitleLoadingBorder = "Title-LoadGameBox"
  21.   TitleLoadingBar = "Title-LoadBar"
  22. end
  23.  
  24. #===============================================================================
  25. # Modificações erradas abaixo pode provocar o mal ou o não funcionamento do
  26. # script.
  27. #===============================================================================
  28.  
  29. class Scene_Title < Scene_Base
  30. include Title_Images
  31.   #-----------------------------------------------------------------------------
  32.   # Criação do Background.
  33.   #-----------------------------------------------------------------------------
  34.   def create_background
  35.     @background = Sprite.new
  36.     @background.bitmap = Cache.system(TitleBackground)
  37.     center_sprite(@background)
  38.     @background.z = 1
  39.   end
  40.  
  41.   def dispose_background
  42.     @background.bitmap.dispose
  43.     @background.dispose
  44.   end
  45.   #-----------------------------------------------------------------------------
  46.   # Criação das imagens de Press Start.
  47.   #-----------------------------------------------------------------------------
  48.   def create_press_start
  49.     @press_start = Sprite.new
  50.     @press_start.bitmap = Cache.system(TitlePressStart)
  51.     center_sprite(@press_start)
  52.     @press_start.z = 100
  53.     @press_start2 = Sprite.new
  54.     @press_start2.bitmap = Cache.system(TitlePressStart)
  55.     center_sprite(@press_start2)
  56.     @press_start2.z = 101
  57.     @press_start2.visible = false
  58.   end
  59.  
  60.   def dispose_press_start
  61.     @press_start.bitmap.dispose
  62.     @press_start.dispose
  63.   end
  64.  
  65.   def dispose_press_start2
  66.     @press_start2.bitmap.dispose
  67.     @press_start2.dispose
  68.   end
  69.   #-----------------------------------------------------------------------------
  70.   # Criação da imagem do Nome/Logo.
  71.   #-----------------------------------------------------------------------------
  72.   def create_name_project
  73.     @name_project = Sprite.new
  74.     @name_project.bitmap = Cache.system(TitleName)
  75.     center_sprite(@name_project)
  76.     @name_project.opacity = 0
  77.     @name_project.z = 200
  78.   end
  79.    
  80.   def dispose_name_project
  81.     @name_project.bitmap.dispose
  82.     @name_project.dispose
  83.   end
  84.   #-----------------------------------------------------------------------------
  85.   # Criação da imagem das Opções.
  86.   #-----------------------------------------------------------------------------
  87.   def create_options_img
  88.     @options_img = Sprite.new
  89.     @options_img2 = Sprite.new
  90.     if continue_enabled
  91.       @options_img.bitmap = Cache.system(TitleContinue)
  92.       @options_img2.bitmap = Cache.system(TitleContinue)
  93.     else
  94.       @options_img.bitmap = Cache.system(TitleNewGame)
  95.       @options_img2.bitmap = Cache.system(TitleNewGame)
  96.     end
  97.     @options_img.x += 125
  98.     @options_img.y = 0
  99.     @options_img.opacity = 0
  100.     @options_img.z = 250
  101.     @options_img2.x -= 125
  102.     @options_img2.y = 0
  103.     @options_img2.opacity = 0
  104.     @options_img2.z = 251
  105.   end
  106.  
  107.   def dispose_options_img
  108.     @options_img.bitmap.dispose
  109.     @options_img.dispose
  110.   end
  111.  
  112.   def dispose_options_img2
  113.     @options_img2.bitmap.dispose
  114.     @options_img2.dispose
  115.   end
  116.   #-----------------------------------------------------------------------------
  117.   # Barra de Loading.
  118.   #-----------------------------------------------------------------------------
  119.   def create_loading_box
  120.     @loading_box = Sprite.new
  121.     @loading_box.bitmap = Cache.system(TitleLoadingBorder)
  122.     center_sprite(@loading_box)
  123.     @loading_box.opacity = 0
  124.     @loading_box.z = 200
  125.   end
  126.  
  127.   def create_loading_bar
  128.     @loading_bar = Sprite.new
  129.     @loading_bar.bitmap = Cache.system(TitleLoadingBar)
  130.     @loading_bar.opacity = 0
  131.     @loading_bar.x = 24
  132.     @loading_bar.y = 361
  133.     @loading_bar.zoom_x = 0.00
  134.     @size_bar1 = 0.00
  135.     @size_bar2 = 200.00
  136.     @size_bar_final = 0.00
  137.     @loading_bar.z = 100
  138.   end
  139.  
  140.   def dispose_loading_box
  141.     @loading_box.bitmap.dispose
  142.     @loading_box.dispose
  143.   end
  144.  
  145.   def dispose_loading_bar
  146.     @loading_bar.bitmap.dispose
  147.     @loading_bar.dispose
  148.   end
  149.   #-----------------------------------------------------------------------------
  150.   # Inicialização do processo da Scene Title.
  151.   #-----------------------------------------------------------------------------
  152.   def start
  153.     super
  154.     @press_button = false
  155.     @press_button_move = false
  156.     @eneabled_options = false
  157.     @show_name_project = false
  158.     @change_options = false
  159.     @loading = false
  160.     SceneManager.clear
  161.     Graphics.freeze
  162.     create_background
  163.     create_press_start
  164.     create_name_project
  165.     create_options_img
  166.     create_loading_box
  167.     create_loading_bar
  168.     create_command_window
  169.     play_title_music
  170.   end
  171.  
  172.   def update
  173.     super
  174.     @press_start.visible = false if Graphics.frame_count % 18 == 0 && @press_button == false
  175.     @press_start.visible = true if Graphics.frame_count % 36 == 0 && @press_button == false
  176.     if @press_button == false
  177.       if Input.trigger?(:C)
  178.         Sound.play_ok
  179.         @press_button = true
  180.         @press_button_move = true
  181.         @press_start2.visible = true
  182.         @press_start2.opacity = 255
  183.       end
  184.     end
  185.     if @press_button_move == true
  186.       if @press_start.x <= 400
  187.         @press_start.x += 4
  188.         @press_start.opacity -= 15
  189.         @press_start2.x -= 4
  190.         @press_start2.opacity -= 15
  191.       else
  192.         @press_start.visible = false
  193.         @press_start2.visible = false
  194.         @press_button_move = false
  195.         @show_name_project = true
  196.       end
  197.     end
  198.     if @show_name_project == true
  199.       if @name_project.opacity < 255
  200.         @name_project.opacity += 5
  201.       else
  202.         @eneabled_options = true
  203.         @show_name_project = false
  204.       end
  205.     end
  206.     if @eneabled_options == true
  207.       if @options_img.x >= 0
  208.         @options_img.x -= 5
  209.         @options_img.opacity += 10
  210.         @options_img2.x += 5
  211.         @options_img2.opacity += 10
  212.       else
  213.         @options_img.x = 0
  214.         @options_img2.visible = false
  215.         @command_window.visible = true
  216.         @command_window.activate
  217.         @change_options = true
  218.         @eneabled_options = false
  219.       end
  220.     end
  221.     if @change_options == true
  222.       if @command_window.index == 0
  223.         @options_img.bitmap = Cache.system(TitleNewGame)
  224.       end
  225.       if @command_window.index == 1
  226.         @options_img.bitmap = Cache.system(TitleContinue)
  227.       end
  228.       if @command_window.index == 2
  229.         @options_img.bitmap = Cache.system(TitleQuit)
  230.       end
  231.     end
  232.     if @loading == true
  233.       if @name_project.opacity > 0
  234.         @name_project.opacity -= 5
  235.         @options_img.opacity -= 5
  236.       else
  237.         if @loading_box.opacity < 255
  238.           @loading_box.opacity += 15
  239.         else
  240.           @loading_bar.opacity = 255
  241.           if @size_bar_final <= 1.00
  242.             @size_bar1 += 1.00
  243.             @size_bar_final = @size_bar1 / @size_bar2
  244.             @loading_bar.zoom_x = @size_bar_final
  245.           else
  246.             DataManager.setup_new_game
  247.             fadeout_all
  248.             $game_map.autoplay
  249.             SceneManager.goto(Scene_Map)
  250.           end
  251.         end
  252.       end
  253.     end
  254.   end
  255.   #-----------------------------------------------------------------------------
  256.   # Aquisição da velocidade de transição
  257.   #-----------------------------------------------------------------------------
  258.   def transition_speed
  259.     return 60
  260.   end
  261.   #-----------------------------------------------------------------------------
  262.   # Finalização do processo
  263.   #-----------------------------------------------------------------------------
  264.   def terminate
  265.     super
  266.     SceneManager.snapshot_for_background
  267.     dispose_background
  268.     dispose_press_start
  269.     dispose_press_start2
  270.     dispose_name_project
  271.     dispose_options_img
  272.     dispose_options_img2
  273.     dispose_loading_box
  274.     dispose_loading_bar
  275.   end
  276.   #-----------------------------------------------------------------------------
  277.   # Movimento do sprite para o meio da tela
  278.   #   sprite : sprite a ser movido
  279.   #-----------------------------------------------------------------------------
  280.   def center_sprite(sprite)
  281.     sprite.ox = sprite.bitmap.width / 2
  282.     sprite.oy = sprite.bitmap.height / 2
  283.     sprite.x = Graphics.width / 2
  284.     sprite.y = Graphics.height / 2
  285.   end
  286.   #-----------------------------------------------------------------------------
  287.   # Criação da janela de comando
  288.   #-----------------------------------------------------------------------------
  289.   def create_command_window
  290.     @command_window = Window_TitleCommand.new
  291.     @command_window.set_handler(:new_game, method(:command_new_game))
  292.     @command_window.set_handler(:continue, method(:command_continue))
  293.     @command_window.set_handler(:shutdown, method(:command_shutdown))
  294.     @command_window.deactivate
  295.     @command_window.opacity = 0
  296.     @command_window.contents_opacity = 0
  297.     @command_window.visible = false
  298.   end
  299.   #-----------------------------------------------------------------------------
  300.   # Fechamento da janela de comando
  301.   #-----------------------------------------------------------------------------
  302.   def close_command_window
  303.     @command_window.close
  304.     update until @command_window.close?
  305.   end
  306.   #-----------------------------------------------------------------------------
  307.   # Comando [Novo Jogo]
  308.   #-----------------------------------------------------------------------------
  309.   def command_new_game
  310.     @loading = true
  311.     close_command_window
  312. #    DataManager.setup_new_game
  313. #    fadeout_all
  314. #    $game_map.autoplay
  315. #    SceneManager.goto(Scene_Map)
  316.   end
  317.   #-----------------------------------------------------------------------------
  318.   # Comando [Continuar]
  319.   #-----------------------------------------------------------------------------
  320.   def command_continue
  321.     close_command_window
  322.     SceneManager.call(Scene_Load)
  323.   end
  324.   #-----------------------------------------------------------------------------
  325.   # Comando [Sair]
  326.   #-----------------------------------------------------------------------------
  327.   def command_shutdown
  328.     close_command_window
  329.     fadeout_all
  330.     SceneManager.exit
  331.   end
  332.   #-----------------------------------------------------------------------------
  333.   # Executar música de título
  334.   #-----------------------------------------------------------------------------
  335.   def play_title_music
  336.     $data_system.title_bgm.play
  337.     RPG::BGS.stop
  338.     RPG::ME.stop
  339.   end
  340.   #-----------------------------------------------------------------------------
  341.   # Aquisição do estado de habilitação de continuação
  342.   #-----------------------------------------------------------------------------
  343.   def continue_enabled
  344.     DataManager.save_file_exists?
  345.   end
  346. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement