Advertisement
TroyZ

TroyZ - Loading

Sep 12th, 2013
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.55 KB | None | 0 0
  1. # ==============================================================================
  2. # ▼▼▼▼▼▼                        TroyZ - Loading                         ▼▼▼▼▼▼
  3. # ==============================================================================
  4. # Script by : Agung Prasetyo(TroyZ)
  5. # Contact me by : - Email agung.endisnear.xyz@gmail.com
  6. #                 - Forum RPGMakerID, username TroyZ
  7. #                 - Handphone 085756289121
  8. # Engine : VXAce
  9. # Level : Easy
  10. # Version : 1.0
  11. # ------------------------------------------------------------------------------
  12. # Change Logs :
  13. # 12 September 2013 : Version 1.0 released
  14. # ------------------------------------------------------------------------------
  15. # How this work :
  16. # This script allows you to create a loading bar thingy. The loading bar itself
  17. # can be used by script call. Version 1.0 only allowed you to use this on map
  18. # screen.
  19. # ------------------------------------------------------------------------------
  20. # How to use :
  21. # Place it between material and main. Also don't forget by having a picture of
  22. # loading bar base, the loading bar itself, and the loading text. Put that
  23. # pictures together in the System folder at your project's folder.
  24. #
  25. # Use script call to use this script :
  26. # - SceneManager.call(Agung_Scene_Loading)
  27. # You can alter the speed of loading by using script call :
  28. # - loading_speed(value)
  29. # When value is the new value of speed.
  30. # ------------------------------------------------------------------------------
  31. # Compatibility issues :
  32. # None yet. If you found some, let me know, and bug fixes will come out soon.
  33. # ------------------------------------------------------------------------------
  34. # Who to credit :
  35. # - Allah swt. : For the chance of living that he has given to me.
  36. # - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim.
  37. #                        I'm proud to be your follower. :)
  38. # - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. :P
  39. # ------------------------------------------------------------------------------
  40. # License :
  41. # - Free Game : Just credit those names above.
  42. # - Commercial Game : Same as free game's license.
  43. # ------------------------------------------------------------------------------
  44. $imported = {} if $imported.nil?
  45. $imported[:TroyZ_Loading] = true
  46. # ------------------------------------------------------------------------------
  47. # Configuration of script starts here
  48. # ------------------------------------------------------------------------------
  49. module AGUNG
  50.   module LOADING
  51.     LOADING        = "Loading.png" # the loading text picture
  52.     LOADING_X      = 150  # x position of loading text picture
  53.     LOADING_Y      = 100  # y position of loading text picture
  54.     LOADING_BASE   = "Loading Bar Base.png" # the loading bar base picture
  55.     LOADING_BASE_X = 20   # x position of loading bar base picture
  56.     LOADING_BASE_Y = 208  # y position of loading bar base picture
  57.     LOADING_BAR    = "Loading Bar.png"  # the loading bar picture
  58.     SPEED          = 5    # speed (in pixel) of loading bar
  59.   end
  60. end
  61. # ------------------------------------------------------------------------------
  62. # End of Configuration
  63. # ------------------------------------------------------------------------------
  64.  
  65. # ------------------------------------------------------------------------------
  66. # You shall not pass
  67. # ------------------------------------------------------------------------------
  68. class Game_System
  69.   attr_accessor :loading_speed
  70.  
  71.   alias agung_loading_init_x    initialize
  72.   def initialize
  73.     agung_loading_init_x
  74.     @loading_speed = AGUNG::LOADING::SPEED
  75.   end
  76. end
  77.  
  78. class Game_Interpreter  
  79.   def loading_speed(value)
  80.     $game_system.loading_speed = value
  81.   end  
  82. end
  83.  
  84. class Agung_Scene_Loading < Scene_Base  
  85.   include AGUNG::LOADING
  86.  
  87.   def start
  88.     super
  89.     create_background
  90.     @load_bar_duration = 0
  91.     draw_loading_text
  92.     draw_loading_base
  93.     draw_loading_bar
  94.   end
  95.  
  96.   def draw_loading_text
  97.     @text = Sprite.new
  98.     @text.bitmap = Cache.system(LOADING)
  99.     @text.x = LOADING_X
  100.     @text.y = LOADING_Y
  101.     @text.z = 10
  102.   end
  103.  
  104.   def create_background
  105.     @background_sprite = Sprite.new
  106.     @background_sprite.bitmap = SceneManager.background_bitmap
  107.     @background_sprite.color.set(16, 16, 16, 128)
  108.   end
  109.  
  110.   def draw_loading_base
  111.     @load_base = Sprite.new
  112.     @load_base.bitmap = Cache.system(LOADING_BASE)
  113.     @load_base.x = LOADING_BASE_X
  114.     @load_base.y = LOADING_BASE_Y
  115.     @load_base.z = 900
  116.   end
  117.  
  118.   def draw_loading_bar    
  119.     @load_bar_image = Cache.system(LOADING_BAR)
  120.     @load_bar_bitmap = Bitmap.new(@load_bar_image.width, @load_bar_image.height)
  121.     @load_bar_rect = Rect.new(0, 0, @load_bar_duration, @load_bar_image.height)
  122.     @load_bar_bitmap.blt(0, 0, @load_bar_image, @load_bar_rect)
  123.     @load_bar = Sprite.new
  124.     @load_bar.bitmap = @load_bar_bitmap
  125.     @load_bar.x = LOADING_BASE_X
  126.     @load_bar.y = LOADING_BASE_Y
  127.     @load_bar.z = 950
  128.   end
  129.  
  130.   def update
  131.     super
  132.     @load_bar.bitmap.clear
  133.     @load_bar_rect = Rect.new(0, 0, @load_bar_duration, @load_bar_image.height)
  134.     @load_bar_bitmap.blt(0, 0, @load_bar_image, @load_bar_rect)
  135.     @calc = $game_system.loading_speed
  136.     @load_bar_duration += @calc.to_f
  137.     if @load_bar_duration.to_f > @load_bar_image.width.to_f
  138.       return_scene
  139.     end
  140.   end
  141. end
  142. # ------------------------------------------------------------------------------
  143. # END OF SCRIPT
  144. # ------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement