adiktuzmiko

Animated Title v1.00

Oct 7th, 2014
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.28 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  
  4.  Animated Title v1.00
  5.  by AdiktuzMiko
  6.  --- Date Created: 10/07/2014
  7.  --- Last Date Updated: 10/07/2014
  8.  --- Level: Easy
  9.  
  10.  ==============================================================================
  11.  Overview
  12.  ==============================================================================
  13.  
  14.  This script provides the ability to add pictures on the title screen
  15.  that could be animated.
  16.  
  17.  ==============================================================================
  18.  Set-Up
  19.  ==============================================================================
  20.  
  21.  Just put this script into a blank slot above main but below materials
  22.  (see compatibility section) and modify the settings below
  23.  
  24.  ==============================================================================
  25.  Compatibility
  26.  ==============================================================================
  27.  
  28.  This script aliases Scene_Titles' start and terminate method. It also
  29.  defines the update method for Scene_Title
  30.  
  31.  ==============================================================================
  32.  Terms and Conditions
  33.  ==============================================================================
  34.  
  35.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  36.  
  37.  ==============================================================================
  38. =end
  39.  
  40. module ADIK
  41.   module ANIMATED_TITLE
  42.    
  43.     LIST = {} #Important, Do not delete!
  44.    
  45.     #Pictures should be inside the Graphics\Pictures folder of your game
  46.     #List down the pictures here and their initial setup
  47.     #x,y,w,h,filename,opacity,z
  48.     LIST[0] = [0,0,200,200,"Window.png",255,1]
  49.    
  50.     ANIMATE = {} #Important, Do not delete!
  51.    
  52.     #List down here the final settings of the picture
  53.     #time => time required to finish one animation
  54.     #reverse => reverse the animation once it finishes?
  55.     #loop => will the animation loop once it finishes?
  56.     # if reverse and loop is both true, it will only loop
  57.     # after the reverse
  58.     #x,y,w,h,opacity,time,reverse,loop
  59.     ANIMATE[0] = [400,0,200,200,255,120,true,true]
  60.   end
  61. end
  62.  
  63. # ==============================================================================
  64. # DO NOT EDIT BELOW THIS LINE
  65. # ==============================================================================
  66.  
  67. class Scene_Title
  68.  
  69.   alias start_anim_title_adik start
  70.   def start
  71.     start_anim_title_adik
  72.     @pic_list = []
  73.     ADIK::ANIMATED_TITLE::LIST.each do |key,value|
  74.       @pic_list[key] = []
  75.       @pic_list[key][0] = Sprite.new
  76.       @pic_list[key][0].z = value[6]
  77.       @pic_list[key][0].bitmap = Bitmap.new(Graphics.width,Graphics.height)
  78.       bit = Cache.picture(value[4])
  79.       from_rect = Rect.new(0,0,bit.width,bit.height)
  80.       dest_rect = Rect.new(value[0],value[1],value[2],value[3])
  81.       @pic_list[key][0].bitmap.stretch_blt(dest_rect,bit,from_rect,value[5])
  82.       @pic_list[key][1] = value[0]
  83.       @pic_list[key][2] = value[1]
  84.       @pic_list[key][3] = value[2]
  85.       @pic_list[key][4] = value[3]
  86.       @pic_list[key][5] = value[5]
  87.     end
  88.     @animate = []
  89.     ADIK::ANIMATED_TITLE::ANIMATE.each do |key,value|
  90.       @animate[key] = []
  91.       @animate[key][0] = value[0] - ADIK::ANIMATED_TITLE::LIST[key][0]
  92.       @animate[key][1] = value[1] - ADIK::ANIMATED_TITLE::LIST[key][1]
  93.       @animate[key][2] = value[2] - ADIK::ANIMATED_TITLE::LIST[key][2]
  94.       @animate[key][3] = value[3] - ADIK::ANIMATED_TITLE::LIST[key][3]
  95.       @animate[key][4] = value[4] - ADIK::ANIMATED_TITLE::LIST[key][5]
  96.       @animate[key][5] = value[6]
  97.       @animate[key][10] = value[7]
  98.       @animate[key][0] /= value[5]
  99.       @animate[key][1] /= value[5]
  100.       @animate[key][2] /= value[5]
  101.       @animate[key][3] /= value[5]
  102.       @animate[key][4] /= value[5]
  103.       @animate[key][7] = false
  104.       @animate[key][8] = 0
  105.       @animate[key][9] = value[5]
  106.     end
  107.   end
  108.  
  109.   def update
  110.     super
  111.     @animate.each_index do |key|
  112.       next if @animate[key].nil?
  113.       if @animate[key][7]
  114.         if @animate[key][8] == 0
  115.           @animate[key][7] = false if @animate[key][10]
  116.           next
  117.         end
  118.         @pic_list[key][0].bitmap.clear
  119.         bit = Cache.picture(ADIK::ANIMATED_TITLE::LIST[key][4])
  120.         @pic_list[key][1] -= @animate[key][0]
  121.         @pic_list[key][2] -= @animate[key][1]
  122.         @pic_list[key][3] -= @animate[key][2]
  123.         @pic_list[key][4] -= @animate[key][3]
  124.         @pic_list[key][5] -= @animate[key][4]
  125.         from_rect = Rect.new(0,0,bit.width,bit.height)
  126.         dest_rect = Rect.new(@pic_list[key][1],@pic_list[key][2],@pic_list[key][3],@pic_list[key][4])
  127.         @pic_list[key][0].bitmap.stretch_blt(dest_rect,bit,from_rect,@pic_list[key][5])
  128.         @animate[key][8] -= 1
  129.       else
  130.         if @animate[key][8] == @animate[key][9]
  131.           if @animate[key][5]
  132.             @animate[key][7] = true
  133.             next
  134.           else
  135.             #only process loop if reverse is false
  136.             if @animate[key][10]
  137.               @pic_list[key][1] = ADIK::ANIMATED_TITLE::LIST[key][0]
  138.               @pic_list[key][2] = ADIK::ANIMATED_TITLE::LIST[key][1]
  139.               @pic_list[key][3] = ADIK::ANIMATED_TITLE::LIST[key][2]
  140.               @pic_list[key][4] = ADIK::ANIMATED_TITLE::LIST[key][3]
  141.               @pic_list[key][5] = ADIK::ANIMATED_TITLE::LIST[key][5]
  142.               @animate[key][8] = 0
  143.             else
  144.               next
  145.             end
  146.           end
  147.         end
  148.         @pic_list[key][0].bitmap.clear
  149.         bit = Cache.picture(ADIK::ANIMATED_TITLE::LIST[key][4])
  150.         @pic_list[key][1] += @animate[key][0]
  151.         @pic_list[key][2] += @animate[key][1]
  152.         @pic_list[key][3] += @animate[key][2]
  153.         @pic_list[key][4] += @animate[key][3]
  154.         @pic_list[key][5] += @animate[key][4]
  155.         from_rect = Rect.new(0,0,bit.width,bit.height)
  156.         dest_rect = Rect.new(@pic_list[key][1],@pic_list[key][2],@pic_list[key][3],@pic_list[key][4])
  157.         @pic_list[key][0].bitmap.stretch_blt(dest_rect,bit,from_rect,@pic_list[key][5])
  158.         @animate[key][8] += 1
  159.       end
  160.     end
  161.   end
  162.  
  163.   alias terminate_anim_title_adik terminate
  164.   def terminate
  165.     unless @pic_list.nil?
  166.       @pic_list.each {|pic| pic[0].dispose}
  167.     end
  168.     terminate_anim_title_adik
  169.   end
  170.  
  171. end
Advertisement
Add Comment
Please, Sign In to add comment