SHARE
TWEET

MOG - Title Multibackground - [Stand Alone Series] (V1.1)

a guest Mar 26th, 2015 242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if true
  2. #==============================================================================
  3. # +++ MOG - Title Multibackground  - [Stand Alone Series] (V1.1) +++
  4. #==============================================================================
  5. # By Moghunter
  6. # https://atelierrgss.wordpress.com/
  7. #==============================================================================
  8. # Adiciona  múltiplas camadas animadas na tela de titulo.
  9. #==============================================================================
  10. module MOG_TITLE_BACKGROUND
  11.   BACKGROUND_EFFECT = []
  12.   #=============================================================================
  13.   #
  14.   # BACKGROUND_EFFECT[ A ] = [B , C , D, E ,F]
  15.   #
  16.   # A - LAYER ID
  17.   # B - EFFECT (0 - Scrolling  1 - Waving)
  18.   # C - SPEED X  / Wave Power
  19.   # D - SPEED Y  / Wave Speed
  20.   # E - Z-axis
  21.   # F - FILE NAME
  22.   #
  23.   #
  24.   # EX
  25.   #
  26.   # BACKGROUND_EFFECT[0] = [0,4,1,0,"Background_0"]
  27.   # BACKGROUND_EFFECT[1] = [1,5,100,10,"Background_1"]
  28.   # BACKGROUND_EFFECT[2] = [0,20,40,1,"Background_2"]
  29.   # BACKGROUND_EFFECT[3] = [1,10,0,5,"Background_3"]
  30.   # BACKGROUND_EFFECT[4] = [1,5,20,3,"Background_4"]
  31.   # BACKGROUND_EFFECT[5] = [0,0,10,20,"Background_5"]
  32.   # ... BACKGROUND_EFFECT[99] = [1,50,20,32,,"Background_99"]
  33.   #
  34.   #=============================================================================
  35.   BACKGROUND_EFFECT[0] = [0,1,0,0,"Background_0"]
  36.   BACKGROUND_EFFECT[1] = [1,10,10,10,"Background_1"]
  37.   BACKGROUND_EFFECT[2] = [0,0,0,100,"Background_2"]  
  38. end
  39.  
  40. $imported = {} if $imported.nil?
  41. $imported[:mog_title_multibackground] = true
  42.  
  43. #==============================================================================
  44. # ■ Scene Tittle
  45. #==============================================================================
  46. class Scene_Title < Scene_Base  
  47.  
  48.  #--------------------------------------------------------------------------
  49.  # ● Dispose Background
  50.  #--------------------------------------------------------------------------            
  51.   alias mog_t_background_dispose_background dispose_background
  52.   def dispose_background
  53.       mog_t_background_dispose_background
  54.       @sprite_ex_sprite.each {|sprite| next if sprite == nil ; sprite.bitmap.dispose ; sprite.dispose}
  55.   end
  56.  
  57.  #--------------------------------------------------------------------------
  58.  # ● Create Background
  59.  #--------------------------------------------------------------------------            
  60.   def create_background
  61.       @bb_data = [MOG_TITLE_BACKGROUND::BACKGROUND_EFFECT[0],MOG_TITLE_BACKGROUND::BACKGROUND_EFFECT[1]]
  62.       @bb_data[0] = [0,0,0,0] if @bb_data[0] == nil ; @bb_data[1] = [0,0,0,1] if @bb_data[1] == nil
  63.       if @bb_data[0][0] == 0
  64.          @sprite1 = Plane.new ; @sprite1.bitmap = bb_bitmap(0,@bb_data[0])
  65.       else  
  66.          @sprite1 =  Sprite.new ; prepare_wave_effect(@sprite1,0,@bb_data[0])
  67.       end  
  68.       @sprite1.z = @bb_data[0][3]
  69.       if @bb_data[1][0] == 0
  70.          @sprite2 = Plane.new ; @sprite2.bitmap = bb_bitmap(1,@bb_data[1])
  71.       else  
  72.          @sprite2 =  Sprite.new ; prepare_wave_effect(@sprite2,1,@bb_data[1])      
  73.       end
  74.       @sprite2.z = @bb_data[1][3]
  75.       @sprite_ex_sprite = []
  76.       for i in 0...100 ; @bb_data.push(MOG_TITLE_BACKGROUND::BACKGROUND_EFFECT[i + 2]) ; end
  77.       @bb_data.each_with_index do |data, i|
  78.       next if (data == nil or i < 2)
  79.       if data[0] == 0
  80.          @sprite_ex_sprite[i] = Plane.new ; @sprite_ex_sprite[i].bitmap = bb_bitmap(i,data)
  81.       else  
  82.          @sprite_ex_sprite[i] =  Sprite.new ; prepare_wave_effect(@sprite_ex_sprite[i],i,data)      
  83.       end      
  84.       @sprite_ex_sprite[i].z = data[3]
  85.       end    
  86.  end
  87.  
  88.  #--------------------------------------------------------------------------
  89.  # ● Prepare Wave Effect
  90.  #--------------------------------------------------------------------------            
  91.   def prepare_wave_effect(sprite,index,data)
  92.       range = (@bb_data[index][1] + 1) * 5 ; range = 500 if range > 500
  93.       sprite.bitmap = Bitmap.new(Graphics.width + (range * 2),Graphics.height)
  94.       sprite.bitmap.stretch_blt(sprite.bitmap.rect, bb_bitmap(index,data[4]), bb_bitmap(index).rect)
  95.       center_sprite(sprite)
  96.       wave_effect_s(sprite,@bb_data[index])
  97.   end
  98.    
  99.  #--------------------------------------------------------------------------
  100.  # ● BB Bitmap
  101.  #--------------------------------------------------------------------------            
  102.   def bb_bitmap(index,data)
  103.      return Cache.title1(data[4].to_s)
  104.   end
  105.  
  106.  #--------------------------------------------------------------------------
  107.  # ● Wave Effect S
  108.  #--------------------------------------------------------------------------            
  109.   def wave_effect_s(sprite,data)
  110.       sprite.wave_amp = 1 + data[1] ; sprite.wave_speed = 100 + 100 * data[2]
  111.       sprite.wave_length = sprite.bitmap.width ; sprite.x -= sprite.wave_amp / 2
  112.   end
  113.  
  114.  #--------------------------------------------------------------------------
  115.  # ● Update
  116.  #--------------------------------------------------------------------------            
  117.   alias mog_t_background_update update
  118.   def update
  119.       mog_t_background_update
  120.       scroll_bb(@sprite1,@bb_data[0]) ; scroll_bb(@sprite2,@bb_data[1])
  121.       @bb_data.each_with_index do |data, i| ; next if (data == nil or i < 2)
  122.       scroll_bb(@sprite_ex_sprite[i],data) ; end
  123.   end
  124.  
  125.  #--------------------------------------------------------------------------
  126.  # ● Scroll BB
  127.  #--------------------------------------------------------------------------            
  128.   def scroll_bb(sprite,data)
  129.       if data[0] == 0 ; sprite.ox += data[1] ; sprite.oy += data[2]
  130.       else ; sprite.update ; end
  131.   end
  132.  
  133. end  
  134.  
  135. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top