Advertisement
Dark_Paladin

+++ MOG&DP - Animated Gameover (v2.5) Unofficial+++

Jul 8th, 2013
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 20.80 KB | None | 0 0
  1. #==============================================================================
  2. # +++ MOG&DP - Animated Gameover (v2.5) Unofficial+++
  3. #==============================================================================
  4. # Original By Moghunter
  5. # Edited By: Dark Paladin For Game Over Scene.
  6. # http://www.atelier-rgss.com/
  7. # http://dpalpro.blogspot.com/
  8. #==============================================================================
  9. # Animated Gameover screen with logo, random pictures and other visual effects.
  10. #==============================================================================
  11.  
  12. #==============================================================================
  13. # Necessary Images
  14. #==============================================================================
  15. # Place all images in Graphics/Gameover/
  16. #
  17. # Particle.png   (Opcional)
  18. # Animated.png   (Opcional) Can change name
  19. #==============================================================================
  20. #==============================================================================
  21. # ● Histórico (Version History)
  22. #==============================================================================
  23. # V 2.5 Fixed return to title bug.
  24. # V 2.4 Unofficial edit: Script now can play a movie file before gameover scene.
  25. # V 2.3 (Unofficial Dark Paladin Edit)
  26. # - Changed script to work as a gameover screen instead of title
  27. # - Removed unessecary code
  28. # V 2.2 - It is now possible to put negative values to particles movement.
  29. # V 2.1 - Fixed bug when the amount of random images is less than 1.
  30. # V 2.0 - Added Animated Sprite. (Optional)
  31. # - Added random color particles.
  32. # - Added multiple layers of images. (Optional)
  33. # - Added the Wave effect in the text of the title.
  34. # - Option to set the speed of movement of the particles.
  35. # - Option to enable or not the tremor in the selection command.
  36. #
  37. # V 1.2 - Improved system dispose of images.
  38. #
  39. # V 1.1 - Option to skip right by pressing any key.
  40. # - Adding commands in pictures.
  41. # - Addition of cursor control.
  42. #==============================================================================
  43.  
  44. module MOG_SCENE_GO_A
  45.   #--------------------------------------------------------------------------
  46.   # ▼ Movie ▼
  47.   #--------------------------------------------------------------------------  
  48.   #Movie config
  49.   #--------------------------------------------------------------------------
  50.   # Play movie at gameover? true/false
  51.   Play_Movie = false
  52.   # Name of Movie in the Projectfolder/Movies folder
  53.   Movie_Name = "big_buck_bunny"
  54.   # Play Gameover music before video(true) or after(false)
  55.   Start_Music = false
  56.  
  57.   #--------------------------------------------------------------------------
  58.   # ▼ RANDOM BACKGROUND ▼
  59.   #--------------------------------------------------------------------------  
  60.   #Picture config
  61.   #--------------------------------------------------------------------------
  62.   RANDOM_PICTURES = [
  63.   "death-04", "death-01", "Title1", "death-02"  
  64.   #"Title4","Title5","Title6","Title7"
  65.   ]
  66.   #Time between random image transition.
  67.   RANDOM_PICTURES_DURATION = 10#(sec)
  68.   #Use random images true/false.
  69.   RAMDOM_SELECTION = true
  70.   #Speed of Picture scrolling. (Speed X , Speed Y)
  71.   RANDOM_PICTURES_SCROLL_SPEED = [0,0]
  72.  
  73.   #--------------------------------------------------------------------------
  74.   # ▼ MULTIPLE LAYERS ▼
  75.   #--------------------------------------------------------------------------
  76.   # Config for multiple layers. (There is no limit to how many)
  77.   # usadas)
  78.   #--------------------------------------------------------------------------
  79.   # MULTIPLE_LAYERS = [  ["A",B,C,D], ["A",B,C,D], ["A",B,C D], ["A",B,C,D ], ....]
  80.   #
  81.   # A - Name of the image
  82.   # B - Speed of Horizontal Scroll.
  83.   # C - Speed of Vertical Scroll.
  84.   # D - Type of Blending. (0 - Normal / 2 - Add / 3 - Substract)
  85.   #
  86.   MULTIPLE_LAYERS = [
  87.   ["Layer1",1,0,1],
  88.   ["Layer2",3,0,1],  
  89.   ["Layer3",0,0,0]
  90. #  ["Layer4",0,0,0],
  91. #  ["Layer5",0,0,0],
  92. #  ["Layer6",0,0,0]
  93.   ]  
  94.  
  95.   #--------------------------------------------------------------------------
  96.   # ▼ PARTICLES ▼
  97.   #--------------------------------------------------------------------------
  98.   # Adds animated particles to the screen
  99.   # Place the image PARTICLE.png in folder Graphics/Gameover
  100.   #--------------------------------------------------------------------------
  101.   # Use Particles true/false.
  102.   PARTICLE = true
  103.   # Use Random Colors true/false.
  104.   PARTICLE_RANDOM_COLOR = true  
  105.   # Type of Blending. (0,1,2)
  106.   PARTICLE_BLEND_TYPE = 1
  107.   # Speed configuration of the particles.
  108.   PARTICLE_MOVEMENT_RANGE_X = 3
  109.   PARTICLE_MOVEMENT_RANGE_Y = 3
  110.   PARTICLE_ANGLE_RANGE = 3
  111.  
  112.   #--------------------------------------------------------------------------
  113.   # ▼ WAVE TITLE ▼
  114.   #--------------------------------------------------------------------------  
  115.   # Configure for the Title name Wave. Place the image in Graphics/Gameover
  116.   #--------------------------------------------------------------------------    
  117.   # Wave Active true/false.
  118.   TITLE_WAVE = true
  119.   # TITLE_WAVE_CONFIG = [ POWER, LENGTH , SPEED]
  120.   TITLE_WAVE_CONFIG = [6 , 232 , 360]
  121.   # Filename for the Gameover text
  122.   GameoverTextImage = "gameover"
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # ▼ ANIMATED_SPRITE ▼ (Opcional)
  126.   #--------------------------------------------------------------------------
  127.   # Adds an animated sprite to the background.
  128.   # The number of frames is mesured from the height divide by the width
  129.   # There is no limit to the number of frames you can have.
  130.   # Place the image canbedefinedbelow.png (Jpg) in the Graphics/Gameover folder
  131.   #--------------------------------------------------------------------------
  132.   # Activate animated sprite true/false.
  133.   ANIMATED_SPRITE = true
  134.   # Sprite position.
  135.   ANIMATED_SPRITE_POSITION = [20,-30]
  136.   # Speed of Animation
  137.   ANIMATED_SPRITE_SPEED = 10
  138.   # Type of Blending. (0 - Normal / 2 - Add / 3 - Substract)
  139.   ANIMATED_SPRITE_BLEND_TYPE = 1
  140.   # Zoom size 1.0 is normal,
  141.   ANIMATED_SPRITE_ZOOM = 2.7
  142.   # Filename for the  animated sprite
  143.   Sprite_Fname = "ANIMATED"
  144.  
  145. end
  146. #==============================================================================
  147. # ■ Cache Extension
  148. #==============================================================================
  149. module Cache
  150.     def self.gameover(filename)
  151.     load_bitmap("Graphics/Gameover/", filename)
  152.   end
  153.   def self.movies(filename)
  154.     Graphics.play_movie("Movies/" + filename)
  155.   end
  156. end
  157. #==============================================================================
  158. # ■ Window TitleCommand
  159. #==============================================================================
  160. class Window_GameEnd < Window_Command
  161.   attr_reader :list
  162. end
  163.  
  164. #==============================================================================
  165. # ■ Particle Title
  166. #==============================================================================
  167. class Particle_Title < Sprite
  168.  
  169.   include MOG_SCENE_GO_A
  170.  
  171.  #--------------------------------------------------------------------------
  172.  # ● Initialize
  173.  #--------------------------------------------------------------------------            
  174.   def initialize(viewport = nil)
  175.       super(viewport)
  176.       self.bitmap = Cache.gameover("Particle")
  177.       self.tone.set(rand(255),rand(255), rand(255), 255) if PARTICLE_RANDOM_COLOR
  178.       self.blend_type = PARTICLE_BLEND_TYPE
  179.       @cw = self.bitmap.width
  180.       @ch = self.bitmap.height
  181.       @nx = PARTICLE_MOVEMENT_RANGE_X
  182.       @ny = PARTICLE_MOVEMENT_RANGE_Y
  183.       reset_setting
  184.   end  
  185.  
  186.  #--------------------------------------------------------------------------
  187.  # ● Reset Setting
  188.  #--------------------------------------------------------------------------              
  189.   def reset_setting
  190.       zoom = (50 + rand(100)) / 100.1
  191.       self.zoom_x = zoom
  192.       self.zoom_y = zoom
  193.       self.x = (rand(576) -32)
  194.       self.y = rand(448 + @ch)
  195.       self.opacity = 0
  196.       self.angle = rand(360)
  197.       nx2 = rand(@nx).abs
  198.       nx2 = 1 if (@nx != 0 and nx2 < 1)      
  199.       @speed_x = @nx > 0 ? nx2 : @nx < 0 ? -nx2 : 0        
  200.       ny2 = rand(@ny).abs
  201.       ny2 = 1 if (@ny != 0 and ny2 < 1)      
  202.       @speed_y = @ny > 0 ? ny2 : @ny < 0 ? -ny2 : 0  
  203.       @speed_a = [[rand(PARTICLE_ANGLE_RANGE), PARTICLE_ANGLE_RANGE].min, 0].max
  204.   end
  205.  
  206.  #--------------------------------------------------------------------------
  207.  # ● Dispose
  208.  #--------------------------------------------------------------------------              
  209.   def dispose
  210.       super
  211.       self.bitmap.dispose
  212.   end  
  213.  
  214.  #--------------------------------------------------------------------------
  215.  # ● Update
  216.  #--------------------------------------------------------------------------              
  217.   def update
  218.       super
  219.       self.x += @speed_x
  220.       self.y -= @speed_y
  221.       self.angle += @speed_a      
  222.       self.opacity += 5
  223.       reset_setting if can_reset_setting?
  224.   end  
  225.  
  226.  #--------------------------------------------------------------------------
  227.  # ● Can Reset Setting
  228.  #--------------------------------------------------------------------------                
  229.   def can_reset_setting?
  230.       return true if (self.x < -48 or self.x > 592)    
  231.       return true if (self.y < -48 or self.y > 464)
  232.       return false
  233.   end  
  234. end
  235.  
  236. #==============================================================================
  237. # ■ Multiple Layers Gameover
  238. #==============================================================================
  239. class Multiple_Layers_Gameover
  240.  
  241.   #--------------------------------------------------------------------------
  242.   # ● Initialize
  243.   #--------------------------------------------------------------------------  
  244.   def self.gameover(filename)
  245.     load_bitmap("Graphics/Gameover/", filename)
  246.   end
  247.   def initialize(name = "", scroll_x = 0, scroll_y = 0, blend = 0, index = 0)
  248.       @layer = Plane.new
  249.       @layer.bitmap = Cache.gameover(name.to_s) rescue nil
  250.       @layer.bitmap = Bitmap.new(32,32) if @layer.bitmap == nil
  251.       @layer.z = 10 + index
  252.       @layer.opacity = 0
  253.       @layer.blend_type = blend
  254.       @scroll_speed = [scroll_x, scroll_y]
  255.   end
  256.  
  257.   #--------------------------------------------------------------------------
  258.   # ● Dispose
  259.   #--------------------------------------------------------------------------  
  260.   def dispose
  261.       @layer.bitmap.dispose
  262.       @layer.bitmap = nil
  263.       @layer.dispose
  264.   end
  265.  
  266.   #--------------------------------------------------------------------------
  267.   # ● Update
  268.   #--------------------------------------------------------------------------  
  269.   def update
  270.       @layer.opacity += 2
  271.       @layer.ox += @scroll_speed[0]
  272.       @layer.oy += @scroll_speed[1]
  273.   end
  274.  
  275. end
  276.  
  277. #==============================================================================
  278. # ■ Scene Gameover
  279. #==============================================================================
  280. class Scene_Gameover < Scene_Base
  281.  include MOG_SCENE_GO_A
  282.  
  283.  #--------------------------------------------------------------------------
  284.  # ● Start
  285.  #--------------------------------------------------------------------------          
  286.  def start
  287.      super
  288.      @movie_active = Play_Movie
  289.      dispose_all_sprites
  290.      RPG::BGM.fade(2000)
  291.      SceneManager.clear
  292.      @phase = 1
  293.      @phase_time = -1
  294.      create_background
  295.      create_light
  296.      create_animated_object
  297.      create_multiple_layers
  298.      if Start_Music == true then play_gameover_music end
  299.      create_movie if @movie_active
  300.      if Start_Music == false then play_gameover_music end
  301. end
  302.  
  303.  
  304.  #--------------------------------------------------------------------------
  305.  # ● Create Gameover Movie
  306.  #--------------------------------------------------------------------------
  307.  def create_movie
  308.    fadeout_frozen_graphics
  309.    Cache.movies(Movie_Name)
  310.   end
  311.  #--------------------------------------------------------------------------
  312.  # ● Create Multiple Layers
  313.  #--------------------------------------------------------------------------          
  314.  def create_multiple_layers
  315.      @m_layers = []
  316.      index = 0
  317.      for i in MULTIPLE_LAYERS
  318.          @m_layers.push(Multiple_Layers_Gameover.new(i[0],i[1],i[2],i[3],index))
  319.          index += 1
  320.      end  
  321.  end
  322.  
  323.  #--------------------------------------------------------------------------
  324.  # ● Create_Logo
  325.  #--------------------------------------------------------------------------            
  326.  def create_animated_object
  327.       return if !ANIMATED_SPRITE
  328.       @object_index = 0
  329.       @object_animation_speed = 0
  330.       @object = Sprite.new
  331.       @object.z = 98
  332.       @object.opacity = 0
  333.       @object.blend_type = ANIMATED_SPRITE_BLEND_TYPE
  334.       @object.zoom_x = ANIMATED_SPRITE_ZOOM
  335.       @object.zoom_y = ANIMATED_SPRITE_ZOOM
  336.       @object_image = Cache.gameover(Sprite_Fname)
  337.       @object_frame_max = @object_image.width / @object_image.height
  338.       @object_width = @object_image.width / @object_frame_max  
  339.       @object.bitmap = Bitmap.new(@object_width,@object_image.height)
  340.       @object.x = ANIMATED_SPRITE_POSITION[0]
  341.       @object.y = ANIMATED_SPRITE_POSITION[1]    
  342.       make_object_bitmap
  343.  end  
  344.  
  345.   #--------------------------------------------------------------------------
  346.   # ● create_background
  347.   #--------------------------------------------------------------------------
  348.   def create_background
  349.       @rand_title_duration = 120
  350.       @old_back_index = 0
  351.       @sprite1 = Plane.new
  352.       @sprite1.opacity = 0
  353.       @sprite1.z = 1
  354.       if RAMDOM_SELECTION
  355.          execute_random_picture(false)
  356.       else
  357.          execute_random_picture(true)
  358.       end
  359.       @sprite2 = Sprite.new
  360.       @sprite2.bitmap = Cache.gameover(GameoverTextImage)
  361.       @sprite2.z = 140
  362.       @sprite2.opacity = 0
  363.       if TITLE_WAVE
  364.           @sprite2.wave_amp = TITLE_WAVE_CONFIG[0]
  365.           @sprite2.wave_length = TITLE_WAVE_CONFIG[1]
  366.           @sprite2.wave_speed = TITLE_WAVE_CONFIG[2]
  367.       end    
  368.   end
  369.  
  370.   #--------------------------------------------------------------------------
  371.   # ● Create Light
  372.   #--------------------------------------------------------------------------  
  373.   def create_light
  374.       return unless PARTICLE
  375.       @viewport_light = Viewport.new(-32, -32, 600, 480)
  376.       @viewport_light.z = 50
  377.       @light_bitmap =[]
  378.       for i in 0...20
  379.           @light_bitmap.push(Particle_Title.new(@viewport_light))
  380.       end  
  381.   end
  382.    
  383.   #--------------------------------------------------------------------------
  384.   # ● dispose Background1
  385.   #--------------------------------------------------------------------------
  386.   def dispose_background1
  387.       @sprite1.bitmap.dispose
  388.       @sprite1.bitmap = nil
  389.       @sprite1.dispose
  390.       @sprite1 = nil
  391.   end
  392.  
  393.  #--------------------------------------------------------------------------
  394.  # ● Dispose Background2
  395.  #--------------------------------------------------------------------------                
  396.   def dispose_background2
  397.       if @sprite2.bitmap != nil
  398.          @sprite2.bitmap.dispose
  399.          @sprite2.bitmap = nil
  400.          @sprite2.dispose
  401.          @sprite2 = nil
  402.       end
  403.   end
  404.    
  405.  #--------------------------------------------------------------------------
  406.  # ● Dispose Light
  407.  #--------------------------------------------------------------------------              
  408.   def dispose_light
  409.       return unless PARTICLE
  410.       if @light_bitmap != nil
  411.          for i in @light_bitmap
  412.              i.dispose
  413.          end
  414.          @light_bitmap = nil
  415.       end
  416.       @viewport_light.dispose
  417.   end    
  418.  
  419.  #--------------------------------------------------------------------------
  420.  # ● Dispose Multiple Layers
  421.  #--------------------------------------------------------------------------                          
  422.  def dispose_multiple_layers
  423.      return if @m_layers == nil
  424.      @m_layers.each {|layer| layer.dispose }
  425.  end
  426.  
  427.  #--------------------------------------------------------------------------
  428.  # ● Terminate
  429.  #--------------------------------------------------------------------------            
  430.  def terminate
  431.      super
  432.      dispose_all_sprites
  433.      goto_title
  434.  end  
  435.  
  436.  #--------------------------------------------------------------------------
  437.  # ● Dispose Title Sprites
  438.  #--------------------------------------------------------------------------            
  439.  def dispose_all_sprites
  440.      return if @cursor == nil
  441.      dispose_background1
  442.      dispose_background2
  443.      dispose_light
  444.      dispose_multiple_layers
  445.      if ANIMATED_SPRITE
  446.         @object.bitmap.dispose
  447.         @object.dispose
  448.         @object_image.dispose
  449.      end        
  450.  end
  451.    
  452.  #--------------------------------------------------------------------------
  453.  # ● Update
  454.  #--------------------------------------------------------------------------            
  455.  def update
  456.      super
  457.      update_background
  458.      update_light
  459.      update_object_animation
  460.      update_multiple_layers
  461.      terminate if Input.trigger?(:C)
  462.  
  463.  end
  464.  
  465.  #--------------------------------------------------------------------------
  466.  # ● Update Multiple Layers
  467.  #--------------------------------------------------------------------------                          
  468.  def update_multiple_layers
  469.      return if @m_layers == nil
  470.      @m_layers.each {|layer| layer.update }
  471.  end
  472.    
  473.  #--------------------------------------------------------------------------
  474.  # ● Make Object bitmap
  475.  #--------------------------------------------------------------------------                        
  476.   def make_object_bitmap
  477.       @object.bitmap.clear
  478.       src_rect_back = Rect.new(@object_width * @object_index, 0,@object_width,@object_image.height)
  479.       @object.bitmap.blt(0,0, @object_image, src_rect_back)  
  480.   end
  481.    
  482.  #--------------------------------------------------------------------------
  483.  # ● Update Object Animation
  484.  #--------------------------------------------------------------------------                      
  485.   def update_object_animation
  486.       return if !ANIMATED_SPRITE
  487.       @object.opacity += 2
  488.       @object_animation_speed += 1
  489.       if @object_animation_speed > ANIMATED_SPRITE_SPEED
  490.          @object_animation_speed = 0
  491.          @object_index += 1
  492.          @object_index = 0 if @object_index >= @object_frame_max
  493.          make_object_bitmap    
  494.       end
  495.   end  
  496.   #--------------------------------------------------------------------------
  497.   # ● Execute Animation S
  498.   #--------------------------------------------------------------------------      
  499.   def execute_animation_s
  500.       @mx[2] += 1
  501.       return if @mx[2] < 4
  502.       @mx[2] = 0
  503.       @mx[0] += 1
  504.       case @mx[0]
  505.          when 1..7;  @mx[1] += 1            
  506.          when 8..14; @mx[1] -= 1
  507.          else
  508.            @mx[0] = 0
  509.            @mx[1] = 0
  510.       end
  511.   end
  512.    
  513.  #--------------------------------------------------------------------------
  514.  # ● Update Background
  515.  #--------------------------------------------------------------------------              
  516.  def update_background
  517.      @sprite1.ox += RANDOM_PICTURES_SCROLL_SPEED[0]
  518.      @sprite1.oy += RANDOM_PICTURES_SCROLL_SPEED[1]
  519.      @sprite2.opacity += 2
  520.      @sprite2.update
  521.      return if RANDOM_PICTURES.size < 1
  522.      @rand_title_duration -= 1
  523.      if @rand_title_duration <= 0
  524.         @sprite1.opacity -= 5 unless RANDOM_PICTURES.size < 2
  525.      else
  526.         @sprite1.opacity += 5
  527.      end  
  528.      return if @sprite1.opacity != 0
  529.      execute_random_picture
  530.  end
  531.  
  532.  #--------------------------------------------------------------------------
  533.  # ● Execute Random Picture
  534.  #--------------------------------------------------------------------------              
  535.  def execute_random_picture(initial = false)
  536.      @rand_title_duration = [[60 * RANDOM_PICTURES_DURATION, 9999].min, 60].max
  537.      if @sprite1.bitmap != nil
  538.         @sprite1.bitmap.dispose
  539.         @sprite1.bitmap = nil
  540.      end
  541.      if RAMDOM_SELECTION
  542.          rand_pic = rand(RANDOM_PICTURES.size)
  543.          if rand_pic == @old_back_index
  544.             rand_pic += 1
  545.             rand_pic = 0 if rand_pic >= RANDOM_PICTURES.size
  546.          end
  547.          @old_back_index = rand_pic  
  548.      else
  549.          @old_back_index += 1 unless initial
  550.          @old_back_index = 0 if @old_back_index >= RANDOM_PICTURES.size
  551.      end
  552.      pic = RANDOM_PICTURES[@old_back_index]
  553.      @sprite1.bitmap = Cache.gameover(pic) rescue nil
  554.      @sprite1.bitmap = Cache.gameover("") if @sprite1.bitmap == nil
  555.  end
  556.  #--------------------------------------------------------------------------
  557.  # ● Update Light
  558.  #--------------------------------------------------------------------------              
  559.  def update_light
  560.      return unless PARTICLE
  561.      if @light_bitmap != nil
  562.         for i in @light_bitmap
  563.             i.update
  564.         end  
  565.      end  
  566.  end
  567. end
  568.  
  569.  
  570.  
  571.  
  572. $mog_rgss3_animated_go_a = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement