TheoAllen

Theo - Fog Menu

May 23rd, 2013
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.48 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Fog menu
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_FogMenu] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.05.24 - Started and Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini ngebikin kamu bisa nampilin fog di menu.
  17.  
  18.   Cara penggunaan :
  19.   Pasang di bawah material namun di atas main
  20.   Edit konfigurasinya
  21.  
  22.   Dibawah ini untuk penggunaan script call. kalo sewaktu-waktu u pengen ganti
  23.   fog menu pas di tengah permainan.
  24.  
  25.   - $game_system.fog_menu_name      = "namafilenya"
  26.   - $game_system.fog_menu_opacity   = (0 s.d 255)
  27.   - $game_system.fog_menu_scroll_x  = (bilangan bulat)
  28.   - $game_system.fog_menu_scroll_y  = (bilangan bulat)
  29.   - $game_system.fog_menu_variance  = (bilangan bulat)
  30.   - $game_system.fog_menu_speed     = (bilangan bulat)
  31.   - $game_system.fog_behind_menu    = (true/false)
  32.  
  33.   Terms of use :
  34.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  35.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  36.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  37.  
  38. =end
  39. # =============================================================================
  40. # Konfigurasi :
  41. # =============================================================================
  42. module THEO
  43.   module FOG
  44.    
  45.     FOG_NAME      = "fogx"  # Nama fog (harus ada di Graphics/picture)
  46.     FOG_OPACITY   = 255     # Opacity fognya
  47.     FOG_SCROLL_X  = -1      # Loop horizontal (minus = ke kanan)
  48.     FOG_SCROLL_Y  = -1      # Loop vertikal (minus = ke bawah)
  49.    
  50.     OPACITY_VARIANCE  = 0   # Variasi opacitynya
  51.     FADE_SPEED        = 1   # Kecepatan berubah opacitynya
  52.    
  53.     BEHIND_MENU     = true  # Set true kalo pengen fog ada di belakang menu
  54.     HIDE_SWITCH_ID  = 0     # Fog di sembunyiin kalo switch dengan id ini ON
  55.    
  56.   end
  57. end
  58. # =============================================================================
  59. # Akhir dari konfigurasi. Jangan diedit kecuali ente ngerti
  60. # =============================================================================
  61. class Game_System
  62.   attr_accessor :fog_menu_name
  63.   attr_accessor :fog_menu_opacity
  64.   attr_accessor :fog_menu_scroll_x
  65.   attr_accessor :fog_menu_scroll_y
  66.   attr_accessor :fog_menu_variance
  67.   attr_accessor :fog_menu_speed
  68.   attr_accessor :fog_behind_menu
  69.  
  70.   include THEO::FOG
  71.  
  72.   alias pre_fog_menu_init initialize
  73.   def initialize
  74.     pre_fog_menu_init
  75.     init_fog_menu_member
  76.   end
  77.  
  78.   def init_fog_menu_member
  79.     @fog_menu_name = FOG_NAME
  80.     @fog_menu_opacity = FOG_OPACITY
  81.     @fog_menu_scroll_x = FOG_SCROLL_X
  82.     @fog_menu_scroll_y = FOG_SCROLL_Y
  83.     @fog_menu_variance = OPACITY_VARIANCE
  84.     @fog_menu_speed = FADE_SPEED
  85.     @fog_behind_menu = BEHIND_MENU
  86.   end
  87.  
  88. end
  89.  
  90. class Scene_MenuBase < Scene_Base
  91.  
  92.   alias pre_fog_menu_start start
  93.   def start
  94.     pre_fog_menu_start
  95.     create_fog_menu
  96.     @fog_count = 0
  97.   end
  98.  
  99.   def create_fog_menu
  100.     @fog_menu = Plane.new($game_system.fog_behind_menu ? nil : @viewport)
  101.     @fog_menu.bitmap = Cache.picture($game_system.fog_menu_name) rescue return
  102.     @fog_menu.opacity = $game_system.fog_menu_opacity
  103.   end
  104.  
  105.   alias pre_fog_update update
  106.   def update
  107.     pre_fog_update
  108.     update_fog_menu
  109.   end
  110.  
  111.   def update_fog_menu
  112.     update_fog_scroll
  113.     update_fog_opacity
  114.     update_fog_visibility
  115.   end
  116.  
  117.   def update_fog_scroll
  118.     @fog_menu.ox += $game_system.fog_menu_scroll_x
  119.     @fog_menu.oy += $game_system.fog_menu_scroll_y
  120.   end
  121.  
  122.   def update_fog_opacity
  123.     derajat = (@fog_count.to_f/180) * Math::PI
  124.     @fog_menu.opacity = $game_system.fog_menu_opacity +
  125.       (Math.sin(derajat) * $game_system.fog_menu_variance)
  126.     @fog_count += (rand * $game_system.fog_menu_speed)
  127.   end
  128.  
  129.   def update_fog_visibility
  130.     @fog_menu.visible = !$game_switches[THEO::FOG::HIDE_SWITCH_ID]
  131.   end
  132.  
  133.   alias pre_fog_terminate terminate
  134.   def terminate
  135.     dispose_fog_menu
  136.     pre_fog_terminate
  137.   end
  138.  
  139.   def dispose_fog_menu
  140.     @fog_menu.dispose
  141.   end
  142.  
  143. end
Advertisement
Add Comment
Please, Sign In to add comment