TheoAllen

Theo - Cutscene Screen

Mar 18th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.36 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Cutscene Screen
  3. # Version : 0.x
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # -----------------------------------------------------------------------------
  7. # Requires :
  8. # >> Theo - Core Movement (Basic Modules)
  9. # >> Theo - Core Fade (Basic Modules)
  10. # =============================================================================
  11. ($imported ||= {})[:Theo_Cutscreen] = true
  12. # =============================================================================
  13. # Change Logs:
  14. # -----------------------------------------------------------------------------
  15. # -
  16. # =============================================================================
  17. =begin
  18.  
  19.   Perkenalan :
  20.   Script ini ngebuat screen RM kamu dipotong atas bawah sehingga tampak seperti
  21.   film.
  22.  
  23.   Cara penggunaan :
  24.   Pasang script ini di bawah material namun di atas main
  25.   Gunakan script call seperti berikut
  26.  
  27.   start_cutscene(durasi)
  28.   end_cutscene(durasi)
  29.  
  30.   Ganti durasi dengan angka.
  31.  
  32.   Terms of use :
  33.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  34.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  35.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.        
  36.  
  37. =end
  38. # =============================================================================
  39. # Konfig ~
  40. # =============================================================================
  41. module Theo
  42.   module Cutscene
  43.    
  44.     Solid_Size    = 10
  45.     Gradient_Size = 45
  46.    
  47.   end
  48. end
  49. # =============================================================================
  50. # Akhir konfig ~
  51. # =============================================================================
  52. class Game_Interpreter
  53.  
  54.   def start_cutscene(dur)
  55.     get_spriteset.start_cutscene(dur)
  56.   end
  57.  
  58.   def end_cutscene(dur)
  59.     get_spriteset.end_cutscene(dur)
  60.   end
  61.  
  62. end
  63.  
  64. class Game_Temp
  65.   attr_accessor :cutscene
  66. end
  67.  
  68. class Cut_Sprites
  69.   attr_reader :location
  70.  
  71.   def initialize(viewport, location)
  72.     @viewport = viewport
  73.     @solid_sprite = Sprite.new(viewport)
  74.     @gradient_sprite = Sprite.new(viewport)
  75.     @location = location
  76.     width = Graphics.width
  77.     @bitmap1 = Bitmap.new(width,Theo::Cutscene::Solid_Size)
  78.     @bitmap2 = Bitmap.new(width,Theo::Cutscene::Gradient_Size)
  79.     color1 = Color.new(0,0,0,255)
  80.     color2 = Color.new(0,0,0,0)
  81.     @solid_sprite.bitmap = @bitmap1
  82.     @gradient_sprite.bitmap = @bitmap2
  83.     @bitmap1.fill_rect(@bitmap1.rect,color1)
  84.     if location == :up
  85.       @bitmap2.gradient_fill_rect(@bitmap2.rect, color1, color2,true)
  86.       @solid_sprite.y = 0
  87.       @gradient_sprite.y = @solid_sprite.height
  88.     else
  89.       @bitmap2.gradient_fill_rect(@bitmap2.rect, color2, color1,true)
  90.       @solid_sprite.y = Graphics.height - @solid_sprite.height
  91.       @gradient_sprite.y = @solid_sprite.y - @gradient_sprite.height
  92.     end
  93.     @solid_sprite.z = 10
  94.     @gradient_sprite.z = 10
  95.     hide_position
  96.   end
  97.  
  98.   def hide_position
  99.     if location == :up
  100.       @solid_sprite.y -= total_height
  101.       @gradient_sprite.y -= total_height
  102.     else
  103.       @solid_sprite.y += total_height
  104.       @gradient_sprite.y += total_height
  105.     end
  106.   end
  107.  
  108.   def total_height
  109.     Theo::Cutscene::Solid_Size + Theo::Cutscene::Gradient_Size
  110.   end
  111.  
  112.   def update
  113.     @solid_sprite.update
  114.     @gradient_sprite.update
  115.   end
  116.  
  117.   def start(dur)
  118.     if location == :up
  119.       @solid_sprite.down(total_height,dur)
  120.       @gradient_sprite.down(total_height,dur)
  121.     else
  122.       @solid_sprite.up(total_height,dur)
  123.       @gradient_sprite.up(total_height,dur)
  124.     end
  125.   end
  126.  
  127.   def end(dur)
  128.     if location == :up
  129.       @solid_sprite.up(total_height,dur)
  130.       @gradient_sprite.up(total_height,dur)
  131.     else
  132.       @solid_sprite.down(total_height,dur)
  133.       @gradient_sprite.down(total_height,dur)
  134.     end
  135.   end
  136.  
  137.   def dispose
  138.     @solid_sprite.dispose
  139.     @gradient_sprite.dispose
  140.     @bitmap1.dispose
  141.     @bitmap2.dispose
  142.   end
  143.  
  144. end
  145.  
  146. class Spriteset_Cutscene
  147.  
  148.   def initialize(viewport)
  149.     @sprite_up = Cut_Sprites.new(viewport, :up)
  150.     @sprite_down = Cut_Sprites.new(viewport, :down)
  151.   end
  152.  
  153.   def update
  154.     @sprite_up.update
  155.     @sprite_down.update
  156.   end
  157.  
  158.   def dispose
  159.     @sprite_up.dispose
  160.     @sprite_down.dispose
  161.   end
  162.  
  163.   def start(dur)
  164.     return if $game_temp.cutscene
  165.     @sprite_up.start(dur)
  166.     @sprite_down.start(dur)
  167.     $game_temp.cutscene = true
  168.   end
  169.  
  170.   def end(dur)
  171.     return unless $game_temp.cutscene
  172.     @sprite_up.end(dur)
  173.     @sprite_down.end(dur)
  174.     $game_temp.cutscene = false
  175.   end
  176.  
  177. end
  178.  
  179. class Spriteset_Map
  180.  
  181.   alias theo_cutscene_viewport create_viewports
  182.   def create_viewports
  183.     theo_cutscene_viewport
  184.     @cutscene_sprite = Spriteset_Cutscene.new(@viewport3)
  185.   end
  186.  
  187.   alias theo_cutscene_update update
  188.   def update
  189.     theo_cutscene_update
  190.     @cutscene_sprite.update
  191.   end
  192.  
  193.   alias theo_cutscene_dispose dispose
  194.   def dispose
  195.     theo_cutscene_dispose
  196.     @cutscene_sprite.dispose
  197.   end
  198.  
  199.   def start_cutscene(dur)
  200.     @cutscene_sprite.start(dur)
  201.   end
  202.  
  203.   def end_cutscene(dur)
  204.     @cutscene_sprite.end(dur)
  205.   end
  206.  
  207. end
  208.  
  209. def get_spriteset
  210.   SceneManager.scene.instance_variable_get("@spriteset")
  211. end
Advertisement
Add Comment
Please, Sign In to add comment