Guest User

MogHunter

a guest
Dec 7th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 28.83 KB | None | 0 0
  1. #==============================================================================
  2. # +++ MOG - Animated Title A (v2.2) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # http://www.atelier-rgss.com/
  6. #==============================================================================
  7. # Tela de titulo animado, com logo, imagens aleatórias e outros efeitos visuais.
  8. #==============================================================================
  9.  
  10. #==============================================================================
  11. # IMAGENS NECESSÁRIAS
  12. #==============================================================================
  13. # Serão necessários as seguintes imagens na pasta Graphics/Titles2/
  14. #
  15. # Cursor.png  
  16. # Commmand_Name.png (image filename = name of command)
  17. # Particle.png   (Opcional)
  18. # Logo.jpg       (Opcional)
  19. # Animated.png   (Opcional)
  20. #==============================================================================
  21.  
  22. #==============================================================================
  23. # NOTA 1 - Para definir a imagem de texto basta selecionar no banco de dados
  24. # a imagem do titulo numero 2 (Segunda camada)
  25. #==============================================================================
  26.  
  27. #==============================================================================
  28. # NOTA 2 - O nome da imagem de comando é iguál ao nome do comando definido
  29. # no banco de dados do Rpg Maker.
  30. #==============================================================================
  31.  
  32.  
  33. #==============================================================================
  34. # ● Histórico (Version History)
  35. #==============================================================================
  36. # v 2.2 - Possibilidade de colocar valores de movemento negativo nas partículas.
  37. # v 2.1 - Correção do Bug quando a quantidade de imagens aleatórias é definida
  38. #         com a quantidade menor  que 1.
  39. # v 2.0 - Adição do Sprite Animado. (Opcional)
  40. #       - Adição de cores aleatórias nas partículas.
  41. #       - Adição do multiplas camadas de imagens. (Opcional)
  42. #       - Adição do efeito Wave no texto do titulo.  
  43. #       - Opção de definir a velocidade de movimento das partículas.
  44. #       - Opção de ativar ou não o tremor na seleção de comando.
  45. #
  46. # v 1.2 - Melhoria no sistema de dispose de imagens.
  47. #
  48. # v 1.1 - Opção de pular o logo ao apertar alguma tecla.
  49. #       - Adição de comandos em pictures.
  50. #       - Adição de cursor de comando.
  51. #==============================================================================
  52.  
  53. module MOG_SCENE_TITLE_A
  54.  
  55.   #--------------------------------------------------------------------------
  56.   # ▼ LOGO ▼
  57.   #--------------------------------------------------------------------------
  58.   # Apresenta um Logo ao começar a tela de titulo.
  59.   # Será necessário ter a imagem LOGO.jpg (png) na pasta Graphics/Title2
  60.   #--------------------------------------------------------------------------
  61.   # Ativar Logo
  62.   LOGO = true
  63.   # Duração do logo.
  64.   LOGO_DURATION = 2 #(Sec)
  65.  
  66.   #--------------------------------------------------------------------------
  67.   # ▼ RANDOM BACKGROUND ▼
  68.   #--------------------------------------------------------------------------  
  69.   #Definição das pictures.
  70.   #--------------------------------------------------------------------------
  71.   RANDOM_PICTURES = [
  72.   "0_Title1-A", "0_Title2-A", "0_Title3-A", "0_Title4-A"  
  73.   #"Title4","Title5","Title6","Title7"
  74.   ]
  75.   #Tempo de duração para ativar a troca de imagens.
  76.   RANDOM_PICTURES_DURATION = 6#(sec)
  77.   #Seleção aleatória.
  78.   RAMDOM_SELECTION = true
  79.   #Velocidade de Scrolling. (Speed X , Speed Y)
  80.   RANDOM_PICTURES_SCROLL_SPEED = [0,0]
  81.  
  82.   #--------------------------------------------------------------------------
  83.   # ▼ MULTIPLE LAYERS ▼
  84.   #--------------------------------------------------------------------------
  85.   # Definição de multiplas camadas. * (não há limíte na quantidade de camadas
  86.   # usadas)
  87.   #--------------------------------------------------------------------------
  88.   # MULTIPLE_LAYERS = [  ["A",B,C,D], ["A",B,C,D], ["A",B,C D], ["A",B,C,D ], ....]
  89.   #
  90.   # A - Nome da imagem.
  91.   # B - Velocidade de scroll na horizontal.
  92.   # C - Velocidade de scroll na vertical.
  93.   # D - Tipo de Blend. (0 - Normal / 2 - Add / 3 - Substract)
  94.   #
  95.   MULTIPLE_LAYERS = [
  96.   ["Layer1",1,0,1],
  97.   ["Layer2",3,0,1],  
  98. #  ["Layer3",0,0,0]
  99. #  ["Layer4",0,0,0],
  100. #  ["Layer5",0,0,0],
  101. #  ["Layer6",0,0,0]
  102.   ]  
  103.  
  104.   #--------------------------------------------------------------------------
  105.   # ▼ PARTICLES ▼
  106.   #--------------------------------------------------------------------------
  107.   # Adiciona partículas animadas na tela do titulo.
  108.   # Será necessário ter a imagem PARTICLE.png na pasta Graphics/Title2
  109.   #--------------------------------------------------------------------------
  110.   # Ativar Partículas.
  111.   PARTICLE = true
  112.   # Ativar Cores Aleatórias.
  113.   PARTICLE_RANDOM_COLOR = true  
  114.   # Definição do tipo de blend. (0,1,2)
  115.   PARTICLE_BLEND_TYPE = 1
  116.   #Definição do limite de velocidade das partículas.
  117.   PARTICLE_MOVEMENT_RANGE_X = 3
  118.   PARTICLE_MOVEMENT_RANGE_Y = 3
  119.   PARTICLE_ANGLE_RANGE = 3
  120.  
  121.   #--------------------------------------------------------------------------
  122.   # ▼ WAVE TITLE ▼
  123.   #--------------------------------------------------------------------------  
  124.   # Ativa o efeito  WAVE no texto do titulo, o Texto do titulo é definido
  125.   # na camada do titulo 2, que pode ser definido através do banco de dados
  126.   #--------------------------------------------------------------------------    
  127.   #Ativar o efeito do titulo com efeito WAVE.
  128.   TITLE_WAVE = false
  129.   #Configuração do efeito WAVE
  130.   #
  131.   # TITLE_WAVE_CONFIG = [ AMP, LENGTH , SPEED]
  132.   #
  133.   TITLE_WAVE_CONFIG = [6 , 232 , 360]
  134.  
  135.   #--------------------------------------------------------------------------
  136.   # ▼ ANIMATED_SPRITE ▼ (Opcional)
  137.   #--------------------------------------------------------------------------
  138.   # Adiciona um sprite animado no titulo.
  139.   # A quantidade de frames é proporcional a largura dividido pela altura
  140.   # da imagem, ou seja, não há limite de quantidade de frames e nem de
  141.   # tamanho da imagem.
  142.   # Será necessário ter a imagem ANIMATED.png (Jpg) na pasta Graphics/Title2
  143.   #--------------------------------------------------------------------------
  144.   # Ativar Sprite animado.
  145.   ANIMATED_SPRITE = false
  146.   # Posição do Sprite animado.
  147.   ANIMATED_SPRITE_POSITION = [130,150]
  148.   # Velocidade da animação
  149.   ANIMATED_SPRITE_SPEED = 10
  150.   # Tipo de Blend. (0 - Normal / 2 - Add / 3 - Substract)
  151.   ANIMATED_SPRITE_BLEND_TYPE = 1
  152.   # Definição do zoom,
  153.   ANIMATED_SPRITE_ZOOM = 1.5
  154.  
  155.  
  156.   #--------------------------------------------------------------------------
  157.   # ▼ COMMANDS / SELECTION ▼
  158.   #--------------------------------------------------------------------------
  159.   # Configuração extras da tela de titulo.
  160.   #--------------------------------------------------------------------------
  161.   # Posição do comando.
  162.   #COMMANDS_POS = [220 , 280]
  163.   COMMANDS_POS = [270 , 280]
  164.   # Ativar o efeito de tremor ao selecionar o comando.
  165.   COMMAND_SHAKE = true
  166.   # Definição da posição do cursor.(Para ajustes)
  167.   #CURSOR_POS = [-42,-7]
  168.   CURSOR_POS = [-5,-7]
  169.   # Ativar flash ao mover o comando.
  170.   CURSOR_FLASH_SELECTION = true
  171.   # Definição da posição do flash.
  172.   CURSOR_FLASH_SLECTION_POS = [-180,0]
  173.   # Tipo de Blend. (0 - Normal / 2 - Add / 3 - Substract)
  174.   CURSOR_FLASH_SLECTION_BLEND_TYPE = 1
  175.  
  176. end
  177.  
  178. #==============================================================================
  179. # ■ Window TitleCommand
  180. #==============================================================================
  181. class Window_TitleCommand < Window_Command
  182.   attr_reader :list
  183. end
  184.  
  185. #==============================================================================
  186. # ■ Particle Title
  187. #==============================================================================
  188. class Particle_Title < Sprite
  189.  
  190.   include MOG_SCENE_TITLE_A
  191.  
  192.  #--------------------------------------------------------------------------
  193.  # ● Initialize
  194.  #--------------------------------------------------------------------------            
  195.   def initialize(viewport = nil)
  196.       super(viewport)
  197.       self.bitmap = Cache.title2("Particle")
  198.       self.tone.set(rand(255),rand(255), rand(255), 255) if PARTICLE_RANDOM_COLOR
  199.       self.blend_type = PARTICLE_BLEND_TYPE
  200.       @cw = self.bitmap.width
  201.       @ch = self.bitmap.height
  202.       @nx = PARTICLE_MOVEMENT_RANGE_X
  203.       @ny = PARTICLE_MOVEMENT_RANGE_Y
  204.       reset_setting
  205.   end  
  206.  
  207.  #--------------------------------------------------------------------------
  208.  # ● Reset Setting
  209.  #--------------------------------------------------------------------------              
  210.   def reset_setting
  211.       zoom = (50 + rand(100)) / 100.1
  212.       self.zoom_x = zoom
  213.       self.zoom_y = zoom
  214.       self.x = (rand(576) -32)
  215.       self.y = rand(448 + @ch)
  216.       self.opacity = 0
  217.       self.angle = rand(360)
  218.       nx2 = rand(@nx).abs
  219.       nx2 = 1 if (@nx != 0 and nx2 < 1)      
  220.       @speed_x = @nx > 0 ? nx2 : @nx < 0 ? -nx2 : 0        
  221.       ny2 = rand(@ny).abs
  222.       ny2 = 1 if (@ny != 0 and ny2 < 1)      
  223.       @speed_y = @ny > 0 ? ny2 : @ny < 0 ? -ny2 : 0  
  224.       @speed_a = [[rand(PARTICLE_ANGLE_RANGE), PARTICLE_ANGLE_RANGE].min, 0].max
  225.   end
  226.  
  227.  #--------------------------------------------------------------------------
  228.  # ● Dispose
  229.  #--------------------------------------------------------------------------              
  230.   def dispose
  231.       super
  232.       self.bitmap.dispose
  233.   end  
  234.  
  235.  #--------------------------------------------------------------------------
  236.  # ● Update
  237.  #--------------------------------------------------------------------------              
  238.   def update
  239.       super
  240.       self.x += @speed_x
  241.       self.y -= @speed_y
  242.       self.angle += @speed_a      
  243.       self.opacity += 5
  244.       reset_setting if can_reset_setting?
  245.   end  
  246.  
  247.  #--------------------------------------------------------------------------
  248.  # ● Can Reset Setting
  249.  #--------------------------------------------------------------------------                
  250.   def can_reset_setting?
  251.       return true if (self.x < -48 or self.x > 592)    
  252.       return true if (self.y < -48 or self.y > 464)
  253.       return false
  254.   end  
  255. end
  256.  
  257. #==============================================================================
  258. # ■ Multiple Layers Title
  259. #==============================================================================
  260. class Multiple_Layers_Title
  261.  
  262.   #--------------------------------------------------------------------------
  263.   # ● Initialize
  264.   #--------------------------------------------------------------------------  
  265.   def initialize(name = "", scroll_x = 0, scroll_y = 0, blend = 0, index = 0)
  266.       @layer = Plane.new
  267.       @layer.bitmap = Cache.title1(name.to_s) rescue nil
  268.       @layer.bitmap = Bitmap.new(32,32) if @layer.bitmap == nil
  269.       @layer.z = 10 + index
  270.       @layer.opacity = 0
  271.       @layer.blend_type = blend
  272.       @scroll_speed = [scroll_x, scroll_y]
  273.   end
  274.  
  275.   #--------------------------------------------------------------------------
  276.   # ● Dispose
  277.   #--------------------------------------------------------------------------  
  278.   def dispose
  279.       @layer.bitmap.dispose
  280.       @layer.bitmap = nil
  281.       @layer.dispose
  282.   end
  283.  
  284.   #--------------------------------------------------------------------------
  285.   # ● Update
  286.   #--------------------------------------------------------------------------  
  287.   def update
  288.       @layer.opacity += 2
  289.       @layer.ox += @scroll_speed[0]
  290.       @layer.oy += @scroll_speed[1]
  291.   end
  292.  
  293. end
  294.  
  295. #==============================================================================
  296. # ■ Scene Title
  297. #==============================================================================
  298. class Scene_Title < Scene_Base
  299.  include MOG_SCENE_TITLE_A
  300.  
  301.  #--------------------------------------------------------------------------
  302.  # ● Start
  303.  #--------------------------------------------------------------------------          
  304.  def start
  305.      super
  306.      RPG::BGM.fade(2000)
  307.      @logo_active = LOGO
  308.      SceneManager.clear
  309.      @phase = 1
  310.      @phase_time = -1
  311.      dispose_title_sprites
  312.      create_logo if @logo_active
  313.      create_command_window
  314.      create_commands
  315.      create_background
  316.      create_light
  317.      create_cursor
  318.      create_animated_object
  319.      create_flash_select
  320.      create_multiple_layers
  321.      play_title_music unless @logo_active
  322.  end
  323.    
  324.  #--------------------------------------------------------------------------
  325.  # ● Create Multiple Layers
  326.  #--------------------------------------------------------------------------
  327.  def create_flash_select
  328.      return if !CURSOR_FLASH_SELECTION
  329.      @flash_select = Sprite.new
  330.      @flash_select.bitmap = Cache.title2("Cursor2")
  331.      @flash_select.z = 99
  332.      @flash_select.opacity = 0
  333.      @flash_select.blend_type = CURSOR_FLASH_SLECTION_BLEND_TYPE
  334.  end  
  335.  
  336.  #--------------------------------------------------------------------------
  337.  # ● Create Multiple Layers
  338.  #--------------------------------------------------------------------------          
  339.  def create_multiple_layers
  340.      @m_layers = []
  341.      index = 0
  342.      for i in MULTIPLE_LAYERS
  343.          @m_layers.push(Multiple_Layers_Title.new(i[0],i[1],i[2],i[3],index))
  344.          index += 1
  345.      end  
  346.  end
  347.  
  348.  #--------------------------------------------------------------------------
  349.  # ● Create_Logo
  350.  #--------------------------------------------------------------------------            
  351.  def create_animated_object
  352.       return if !ANIMATED_SPRITE
  353.       @object_index = 0
  354.       @object_animation_speed = 0
  355.       @object = Sprite.new
  356.       @object.z = 98
  357.       @object.opacity = 0
  358.       @object.blend_type = ANIMATED_SPRITE_BLEND_TYPE
  359.       @object.zoom_x = ANIMATED_SPRITE_ZOOM
  360.       @object.zoom_y = ANIMATED_SPRITE_ZOOM
  361.       @object_image = Cache.title2("Animated")
  362.       @object_frame_max = @object_image.width / @object_image.height
  363.       @object_width = @object_image.width / @object_frame_max  
  364.       @object.bitmap = Bitmap.new(@object_width,@object_image.height)
  365.       @object.x = ANIMATED_SPRITE_POSITION[0]
  366.       @object.y = ANIMATED_SPRITE_POSITION[1]    
  367.       make_object_bitmap
  368.  end  
  369.  
  370.  #--------------------------------------------------------------------------
  371.  # ● Create_Logo
  372.  #--------------------------------------------------------------------------          
  373.  def create_cursor
  374.      @cursor = Sprite.new
  375.      @cursor.bitmap = Cache.title2("Cursor")
  376.      @cursor.opacity = 0
  377.      @cursor.z = 130
  378.      @cursor_position = [0,0]
  379.      @mx = [0,0,0]
  380.  end
  381.  
  382.  #--------------------------------------------------------------------------
  383.  # ● Create_Logo
  384.  #--------------------------------------------------------------------------          
  385.  def create_logo
  386.      @phase = 0
  387.      @logo = Sprite.new
  388.      @logo.bitmap = Cache.title2("Logo")
  389.      @logo.opacity = 0
  390.      @logo_duration = 180 + (LOGO_DURATION * 60)
  391.      @logo.z = 200
  392.  end
  393.  
  394.  #--------------------------------------------------------------------------
  395.  # ● Create Commands
  396.  #--------------------------------------------------------------------------          
  397.  def create_commands
  398.      @command_window.visible = false
  399.      @commands_index_old = -1
  400.      @commands = []
  401.      @commands_shake_duration = 0
  402.      index = 0
  403.      for com in @command_window.list
  404.          sprite = Sprite.new
  405.          sprite.bitmap = Cache.title2(com[:name].to_s) rescue nil
  406.          if sprite.bitmap == nil
  407.             sprite.bitmap = Bitmap.new(200,32)
  408.             sprite.bitmap.font.size = 24
  409.             sprite.bitmap.font.bold = true
  410.             sprite.bitmap.font.italic = true
  411.             sprite.bitmap.draw_text(0, 0, 200, 32, com[:name].to_s,1)
  412.          end
  413.          sprite.x = COMMANDS_POS[0] - 100 - (index * 20)
  414.          sprite.y = index * sprite.bitmap.height + COMMANDS_POS[1]
  415.          sprite.z = 100 + index
  416.          sprite.opacity = 0
  417.          index += 1
  418.          @commands.push(sprite)
  419.      end
  420.      @command_max = index  
  421.  end
  422.  
  423.   #--------------------------------------------------------------------------
  424.   # ● create_background
  425.   #--------------------------------------------------------------------------
  426.   def create_background
  427.       @rand_title_duration = 120
  428.       @old_back_index = 0
  429.       @sprite1 = Plane.new
  430.       @sprite1.opacity = 0
  431.       @sprite1.z = 1
  432.       if RAMDOM_SELECTION
  433.          execute_random_picture(false)
  434.       else
  435.          execute_random_picture(true)
  436.       end
  437.       @sprite2 = Sprite.new
  438.       @sprite2.bitmap = Cache.title2("Title")
  439.       @sprite2.z = 140
  440.       @sprite2.opacity = 0
  441.       if TITLE_WAVE
  442.           @sprite2.wave_amp = TITLE_WAVE_CONFIG[0]
  443.           @sprite2.wave_length = TITLE_WAVE_CONFIG[1]
  444.           @sprite2.wave_speed = TITLE_WAVE_CONFIG[2]
  445.       end    
  446.   end
  447.  
  448.   #--------------------------------------------------------------------------
  449.   # ● Create Light
  450.   #--------------------------------------------------------------------------  
  451.   def create_light
  452.       return unless PARTICLE
  453.       @viewport_light = Viewport.new(-32, -32, 600, 480)
  454.       @viewport_light.z = 50
  455.       @light_bitmap =[]
  456.       for i in 0...20
  457.           @light_bitmap.push(Particle_Title.new(@viewport_light))
  458.       end  
  459.   end
  460.    
  461.   #--------------------------------------------------------------------------
  462.   # ● dispose Background1
  463.   #--------------------------------------------------------------------------
  464.   def dispose_background1
  465.       @sprite1.bitmap.dispose
  466.       @sprite1.bitmap = nil
  467.       @sprite1.dispose
  468.       @sprite1 = nil
  469.   end
  470.  
  471.  #--------------------------------------------------------------------------
  472.  # ● Dispose Background2
  473.  #--------------------------------------------------------------------------                
  474.   def dispose_background2
  475.       if @sprite2.bitmap != nil
  476.          @sprite2.bitmap.dispose
  477.          @sprite2.bitmap = nil
  478.          @sprite2.dispose
  479.          @sprite2 = nil
  480.       end
  481.   end
  482.    
  483.  #--------------------------------------------------------------------------
  484.  # ● Dispose Light
  485.  #--------------------------------------------------------------------------              
  486.   def dispose_light
  487.       return unless PARTICLE
  488.       if @light_bitmap != nil
  489.          for i in @light_bitmap
  490.              i.dispose
  491.          end
  492.          @light_bitmap = nil
  493.       end
  494.       @viewport_light.dispose
  495.   end    
  496.  
  497.  #--------------------------------------------------------------------------
  498.  # ● Dispose Logo
  499.  #--------------------------------------------------------------------------            
  500.  def dispose_logo
  501.      return unless @logo_active
  502.      @logo.bitmap.dispose
  503.      @logo.dispose
  504.  end  
  505.  
  506.  #--------------------------------------------------------------------------
  507.  # ● Dispose Multiple Layers
  508.  #--------------------------------------------------------------------------                          
  509.  def dispose_multiple_layers
  510.      return if @m_layers == nil
  511.      @m_layers.each {|layer| layer.dispose }
  512.  end
  513.  
  514.  #--------------------------------------------------------------------------
  515.  # ● Terminate
  516.  #--------------------------------------------------------------------------            
  517.  def terminate
  518.      super
  519.      dispose_title_sprites    
  520.  end  
  521.  
  522.  #--------------------------------------------------------------------------
  523.  # ● Dispose Title Sprites
  524.  #--------------------------------------------------------------------------            
  525.  def dispose_title_sprites
  526.      return if @cursor == nil
  527.      dispose_background1
  528.      dispose_background2
  529.      dispose_light
  530.      dispose_logo
  531.      dispose_multiple_layers
  532.      @cursor.bitmap.dispose
  533.      @cursor.dispose
  534.      @cursor = nil
  535.      if @flash_select != nil
  536.         @flash_select.bitmap.dispose
  537.         @flash_select.dispose
  538.      end  
  539.      for com in @commands
  540.          com.bitmap.dispose
  541.          com.dispose
  542.      end
  543.      if ANIMATED_SPRITE
  544.         @object.bitmap.dispose
  545.         @object.dispose
  546.         @object_image.dispose
  547.      end        
  548.  end
  549.    
  550.  #--------------------------------------------------------------------------
  551.  # ● Update
  552.  #--------------------------------------------------------------------------            
  553.  def update
  554.      super
  555.      update_logo
  556.      update_initial_animation
  557.      update_command
  558.      update_background
  559.      update_light
  560.      update_object_animation
  561.      update_multiple_layers
  562.  end
  563.  
  564.  #--------------------------------------------------------------------------
  565.  # ● Update Multiple Layers
  566.  #--------------------------------------------------------------------------                          
  567.  def update_multiple_layers
  568.      return if @m_layers == nil
  569.      @m_layers.each {|layer| layer.update }
  570.  end
  571.    
  572.  #--------------------------------------------------------------------------
  573.  # ● Make Object bitmap
  574.  #--------------------------------------------------------------------------                        
  575.   def make_object_bitmap
  576.       @object.bitmap.clear
  577.       src_rect_back = Rect.new(@object_width * @object_index, 0,@object_width,@object_image.height)
  578.       @object.bitmap.blt(0,0, @object_image, src_rect_back)  
  579.   end
  580.    
  581.  #--------------------------------------------------------------------------
  582.  # ● Update Object Animation
  583.  #--------------------------------------------------------------------------                      
  584.   def update_object_animation
  585.       return if !ANIMATED_SPRITE
  586.       @object.opacity += 2
  587.       @object_animation_speed += 1
  588.       if @object_animation_speed > ANIMATED_SPRITE_SPEED
  589.          @object_animation_speed = 0
  590.          @object_index += 1
  591.          @object_index = 0 if @object_index >= @object_frame_max
  592.          make_object_bitmap    
  593.       end
  594.   end  
  595.  
  596.  #--------------------------------------------------------------------------
  597.  # ● Update Cursor Position
  598.  #--------------------------------------------------------------------------            
  599.  def update_cursor_position
  600.      @cursor.opacity += 5
  601.      execute_animation_s
  602.      execute_cursor_move(0,@cursor.x,@cursor_position[0] + @mx[1])
  603.      execute_cursor_move(1,@cursor.y,@cursor_position[1])
  604.  end  
  605.  
  606.   #--------------------------------------------------------------------------
  607.   # ● Execute Animation S
  608.   #--------------------------------------------------------------------------      
  609.   def execute_animation_s
  610.       @mx[2] += 1
  611.       return if @mx[2] < 4
  612.       @mx[2] = 0
  613.       @mx[0] += 1
  614.       case @mx[0]
  615.          when 1..7;  @mx[1] += 1            
  616.          when 8..14; @mx[1] -= 1
  617.          else
  618.            @mx[0] = 0
  619.            @mx[1] = 0
  620.       end
  621.   end
  622.    
  623.   #--------------------------------------------------------------------------
  624.   # ● Execute Cursor Move
  625.   #--------------------------------------------------------------------------      
  626.   def execute_cursor_move(type,cp,np)
  627.       sp = 5 + ((cp - np).abs / 5)
  628.       if cp > np
  629.          cp -= sp
  630.          cp = np if cp < np
  631.       elsif cp < np
  632.          cp += sp
  633.          cp = np if cp > np
  634.       end    
  635.       @cursor.x = cp if type == 0
  636.       @cursor.y = cp if type == 1
  637.   end  
  638.  
  639.  #--------------------------------------------------------------------------
  640.  # ● Update Logo
  641.  #--------------------------------------------------------------------------            
  642.  def update_logo
  643.      return if @phase != 0
  644.      loop do
  645.         break if  @logo_duration == 0
  646.         execute_logo
  647.         Graphics.update
  648.         Input.update
  649.      end
  650.      play_title_music
  651.  end
  652.  
  653.  #--------------------------------------------------------------------------
  654.  # ● Execute Logo
  655.  #--------------------------------------------------------------------------            
  656.  def execute_logo
  657.      if @logo_duration > 120 and (Input.trigger?(:C) or Input.trigger?(:B))
  658.         @logo_duration = 120
  659.      end  
  660.      @logo_duration -= 1
  661.      if @logo_duration > 120
  662.         @logo.opacity += 5
  663.      else
  664.         @logo.opacity -= 5
  665.      end
  666.      if @logo.opacity <= 0
  667.         @logo_duration = 0
  668.         @phase = 1
  669.      end    
  670.  end
  671.    
  672.  #--------------------------------------------------------------------------
  673.  # ● Update Background
  674.  #--------------------------------------------------------------------------              
  675.  def update_background
  676.      @sprite1.ox += RANDOM_PICTURES_SCROLL_SPEED[0]
  677.      @sprite1.oy += RANDOM_PICTURES_SCROLL_SPEED[1]
  678.      @sprite2.opacity += 2
  679.      @sprite2.update
  680.      return if RANDOM_PICTURES.size < 1
  681.      @rand_title_duration -= 1
  682.      if @rand_title_duration <= 0
  683.         @sprite1.opacity -= 5 unless RANDOM_PICTURES.size < 2
  684.      else
  685.         @sprite1.opacity += 5
  686.      end  
  687.      return if @sprite1.opacity != 0
  688.      execute_random_picture
  689.  end
  690.  
  691.  #--------------------------------------------------------------------------
  692.  # ● Execute Random Picture
  693.  #--------------------------------------------------------------------------              
  694.  def execute_random_picture(initial = false)
  695.      @rand_title_duration = [[60 * RANDOM_PICTURES_DURATION, 9999].min, 60].max
  696.      if @sprite1.bitmap != nil
  697.         @sprite1.bitmap.dispose
  698.         @sprite1.bitmap = nil
  699.      end
  700.      if RAMDOM_SELECTION
  701.          rand_pic = rand(RANDOM_PICTURES.size)
  702.          if rand_pic == @old_back_index
  703.             rand_pic += 1
  704.             rand_pic = 0 if rand_pic >= RANDOM_PICTURES.size
  705.          end
  706.          @old_back_index = rand_pic  
  707.      else
  708.          @old_back_index += 1 unless initial
  709.          @old_back_index = 0 if @old_back_index >= RANDOM_PICTURES.size
  710.      end
  711.      pic = RANDOM_PICTURES[@old_back_index]
  712.      @sprite1.bitmap = Cache.title1(pic) rescue nil
  713.      @sprite1.bitmap = Cache.title1("") if @sprite1.bitmap == nil
  714.  end
  715.    
  716.  #--------------------------------------------------------------------------
  717.  # ● Update Light
  718.  #--------------------------------------------------------------------------              
  719.  def update_light
  720.      return unless PARTICLE
  721.      if @light_bitmap != nil
  722.         for i in @light_bitmap
  723.             i.update
  724.         end  
  725.      end  
  726.  end
  727.    
  728.  #--------------------------------------------------------------------------
  729.  # ● Update Initial Animation
  730.  #--------------------------------------------------------------------------              
  731.  def update_initial_animation
  732.      return if @phase != 1
  733.      @phase_time -= 1 if @phase_time > 0
  734.      if @phase_time == 0
  735.         @phase = 2
  736.         @phase_time = 30
  737.      end  
  738.      for i in @commands
  739.         index = 0
  740.         if i.x < COMMANDS_POS[0]
  741.            i.x += 5 + (2 * index)
  742.            i.opacity += 10
  743.            if i.x >= COMMANDS_POS[0]
  744.               i.x = COMMANDS_POS[0]
  745.               i.opacity = 255
  746.               if @phase_time < 15 / 2
  747.                  @phase_time = 15
  748.               end  
  749.            end  
  750.          end
  751.          index += 1
  752.      end  
  753.  end  
  754.  
  755.  #--------------------------------------------------------------------------
  756.  # ● Update Command
  757.  #--------------------------------------------------------------------------              
  758.  def update_command
  759.      return if @phase != 2  
  760.      update_command_slide
  761.      update_cursor_position
  762.      update_flash_select
  763.  end
  764.  
  765.  #--------------------------------------------------------------------------
  766.  # ● Update Command Slide
  767.  #--------------------------------------------------------------------------              
  768.  def update_command_slide
  769.      if @commands_index_old != @command_window.index
  770.         @commands_index_old = @command_window.index
  771.         @commands_shake_duration = 30
  772.         if @flash_select != nil
  773.            @flash_select.opacity = 255
  774.         end  
  775.      end
  776.      return if @commands_shake_duration == 0
  777.      @commands_shake_duration -= 1 if @commands_shake_duration > 0  
  778.      @commands_shake_duration = 0 if !COMMAND_SHAKE
  779.      for i in @commands
  780.        if (i.z - 100) == @command_window.index
  781.           i.opacity += 10
  782.           @cursor_position = [COMMANDS_POS[0] + CURSOR_POS[0],i.y + CURSOR_POS[1]]
  783.           i.x = COMMANDS_POS[0] + rand(@commands_shake_duration)
  784.        else  
  785.           i.opacity -= 7 if i.opacity > 100
  786.           i.x = COMMANDS_POS[0]
  787.        end
  788.      end  
  789.    end
  790.    
  791.  #--------------------------------------------------------------------------
  792.  # ● Update Flash Select
  793.  #--------------------------------------------------------------------------                  
  794.  def update_flash_select
  795.      return if !CURSOR_FLASH_SELECTION
  796.      @flash_select.opacity -= 8
  797.      @flash_select.x = @cursor_position[0] + CURSOR_FLASH_SLECTION_POS[0]
  798.      @flash_select.y = @cursor_position[1] + CURSOR_FLASH_SLECTION_POS[1]    
  799.  end
  800.    
  801. end
  802.  
  803. $mog_rgss3_animated_title_a = true
Advertisement
Add Comment
Please, Sign In to add comment