TheoAllen

Additional pic EX

Jun 20th, 2013
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.27 KB | None | 0 0
  1. # ============================================================================
  2. # (lagi males nulis dokumentasi)
  3. # Theo - In map additional picture
  4. # ----------------------------------------------------------------------------
  5. # 2013.06.23 - Nambahin pergantian opacity
  6. # 2013.06.21 - Nambahin opsi tint screen
  7. # 2013.06.08 - finished script
  8. # ============================================================================
  9. =begin
  10.  
  11.   Cara penggunaan :
  12.   untuk show / hide, gunakan script call
  13.  
  14.   map_picture(true)
  15.   map_picture(false)
  16.  
  17. =end
  18. # ============================================================================
  19. # Konfigurasinya disini :
  20. # ============================================================================
  21. module THEO
  22.   module MAP
  23.  
  24.     ADDITIONAL_PIC_NAME = "framehud"
  25.     INCLUDE_TINT_SCREEN = false
  26.    
  27.     # nilai opacity minimal pas player nyentuh gambar (default : 50)
  28.     MINIMUM_OPACITY = 50
  29.    
  30.     # nilai kecepatan fadenya (default : 20)
  31.     PIC_FADE_SPEED = 20
  32.    
  33.   end
  34. end
  35. # ============================================================================
  36. # Udah ini aja :v
  37. # ============================================================================
  38. class Game_System
  39.   attr_accessor :show_map_picture
  40.  
  41.   alias pre_mappic_init initialize
  42.   def initialize
  43.     pre_mappic_init
  44.     init_mappic_members
  45.   end
  46.  
  47.   def init_mappic_members
  48.     @show_map_picture = true
  49.   end
  50.  
  51. end
  52.  
  53. class Game_Interpreter
  54.  
  55.   # ganti aja nama defnya yg laen kalo ga sreg command script callnya :v
  56.   def map_picture(bool)
  57.     $game_system.show_map_picture = bool
  58.   end
  59.  
  60. end
  61.  
  62. if THEO::MAP::INCLUDE_TINT_SCREEN
  63. class Spriteset_Map
  64.  
  65.   include THEO::MAP
  66.  
  67.   alias pre_pic_create_viewports create_viewports
  68.   def create_viewports
  69.     pre_pic_create_viewports
  70.     @pic = Sprite.new
  71.     @pic.viewport = @viewport2
  72.     @pic.bitmap = Cache.picture(ADDITIONAL_PIC_NAME) rescue return
  73.   end
  74.  
  75.   alias pre_pic_update update
  76.   def update
  77.     pre_pic_update
  78.     @pic.visible = $game_system.show_map_picture
  79.     update_pic_opacity
  80.   end
  81.  
  82.   def update_pic_opacity
  83.     if $game_player.screen_y <= 60 || $game_player.screen_y >= Graphics.height - 32
  84.       @pic.opacity = [@pic.opacity - 20,THEO::MAP::MINIMUM_OPACITY].max
  85.     else
  86.       @pic.opacity = [@pic.opacity + 20,255].min
  87.     end
  88.   end
  89.  
  90.   alias pre_pic_dispose dispose
  91.   def dispose
  92.     pre_pic_dispose
  93.     @pic.dispose
  94.   end
  95.  
  96. end
  97. else
  98.  
  99. class Scene_Map < Scene_Base
  100.  
  101.   include THEO::MAP
  102.   alias pre_inmap_pic_start start
  103.   def start
  104.     pre_inmap_pic_start
  105.     create_map_pic
  106.   end
  107.  
  108.   def create_map_pic
  109.     @pic = Sprite.new
  110.     @pic.bitmap = Cache.picture(ADDITIONAL_PIC_NAME) rescue return
  111.   end
  112.  
  113.   alias pre_inmap_pic_update update
  114.   def update
  115.     pre_inmap_pic_update
  116.     @pic.visible = $game_system.show_map_picture
  117.     update_pic_opacity
  118.   end
  119.  
  120.   def update_pic_opacity
  121.     if $game_player.screen_y <= 60 || $game_player.screen_y >= Graphics.height - 32
  122.       @pic.opacity = [@pic.opacity - PIC_FADE_SPEED,MINIMUM_OPACITY].max
  123.     else
  124.       @pic.opacity = [@pic.opacity + PIC_FADE_SPEED,255].min
  125.     end
  126.   end
  127.  
  128.   alias pre_inmap_pic_terminate terminate
  129.   def terminate
  130.     @pic.dispose
  131.     pre_inmap_pic_terminate
  132.   end
  133.  
  134. end
  135.  
  136. end
Advertisement
Add Comment
Please, Sign In to add comment