khanhdu

Press Start Button

Oct 3rd, 2017
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.81 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Press Start Button
  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_PressStart] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.07.23 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini untuk menampilkan tulisan sebelum title command
  17.  
  18.   Cara penggunaan :
  19.   Pasang dibawah material namun diatas main
  20.   Edit konfigurasinya kalo perlu
  21.  
  22.   Terms of Use :
  23.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  24.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  25.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  26.  
  27. =end
  28. # =============================================================================
  29. # Konfigurasi :
  30. # =============================================================================
  31. module THEO
  32.   module TITLE
  33.    
  34.     # Tulisan sebelum command
  35.     PressStart = "Nhấn Nút Bắt Đầu"
  36.    
  37.     # Font Settings.
  38.     FontName    = ["Jura SemiBold"]
  39.     FontSize    = 48
  40.     FontBold    = true
  41.     FontItalic  = true
  42.    
  43.     # Posisi Y text. Makin gede makin kebawah
  44.     TextPosition = Graphics.height/2 + 120
  45.    
  46.     # Keceptan fadein fadeout. Kalo g pengen ada fadenya, tulis 0
  47.     FadeSpeed = 3
  48.    
  49.   end
  50. end
  51. # =============================================================================
  52. # Akhir dari konfigurasi :
  53. # =============================================================================
  54. module Math
  55.  
  56.   def self.radian(degree)
  57.     return (degree.to_f/180) * Math::PI
  58.   end
  59.  
  60. end
  61.  
  62. class Game_Temp
  63.   attr_accessor :input_title_command
  64.  
  65.   alias theo_prstart_init initialize
  66.   def initialize
  67.     theo_prstart_init
  68.     @input_title_command = false
  69.   end
  70.  
  71. end
  72.  
  73. class Press_Start < Sprite
  74.   attr_accessor :fading
  75.  
  76.   include THEO::TITLE
  77.  
  78.   def initialize(viewport = nil)
  79.     super(viewport)
  80.     self.bitmap = Bitmap.new(Graphics.width,Graphics.height)
  81.     self.opacity = input_mode? ? 0 : (FadeSpeed > 0) ? 128 : 255
  82.     @fading = !input_mode?
  83.     @count = 0
  84.     setup_font
  85.     draw_press_start
  86.   end
  87.  
  88.   def input_mode?
  89.     $game_temp.input_title_command
  90.   end
  91.  
  92.   def setup_font
  93.     font = self.bitmap.font
  94.     font.name = FontName
  95.     font.size = FontSize
  96.     font.bold = FontBold
  97.     font.italic = FontItalic
  98.   end
  99.  
  100.   def text_size(str)
  101.     bitmap.text_size(str)
  102.   end
  103.  
  104.   def draw_press_start
  105.     bitmap.draw_text(rect_for_text,PressStart,1)
  106.   end
  107.  
  108.   def rect_for_text
  109.     text_rect = Rect.new(0,0,self.width,bitmap.font.size)
  110.     text_rect.y = TextPosition
  111.     return text_rect
  112.   end
  113.  
  114.   def update
  115.     super
  116.     update_fading
  117.   end
  118.  
  119.   def update_fading
  120.     @count += FadeSpeed
  121.     return unless @fading || FadeSpeed <= 0
  122.     self.opacity = 128 + (Math.sin(Math.radian(@count))*128)
  123.   end
  124.  
  125. end
  126.  
  127. class Scene_Title < Scene_Base
  128.  
  129.   alias theo_press_start start
  130.   def start
  131.     theo_press_start
  132.     create_press_start
  133.     init_press_start
  134.   end
  135.  
  136.   def create_press_start
  137.     @start = Press_Start.new(@viewport)
  138.   end
  139.  
  140.   def init_press_start
  141.     return if $game_temp.input_title_command
  142.     @command_window.close
  143.     @command_window.deactivate
  144.   end
  145.  
  146.   alias theo_press_start_update update
  147.   def update
  148.     theo_press_start_update
  149.     @start.update
  150.     update_press_start_input
  151.   end
  152.  
  153.   def update_press_start_input
  154.     return if $game_temp.input_title_command
  155.     if Input.trigger?(:C)
  156.       Sound.play_ok
  157.       @start.opacity = 0 if THEO::TITLE::FadeSpeed <= 0
  158.       until @start.opacity == 0
  159.         theo_press_start_update
  160.         @start.update
  161.       end
  162.       @start.fading = false
  163.       open_title_command
  164.     end
  165.   end  
  166.  
  167.   def open_title_command
  168.     @command_window.open
  169.     @command_window.activate
  170.     $game_temp.input_title_command = true
  171.   end
  172.  
  173.   alias theo_prstart_dispose_bg dispose_background
  174.   def dispose_background
  175.     theo_prstart_dispose_bg
  176.     @start.bitmap.dispose
  177.     @start.dispose
  178.   end
  179.  
  180. end
  181.  
  182. class Scene_End < Scene_MenuBase
  183.  
  184.   alias theo_prstart_to_title command_to_title
  185.   def command_to_title
  186.     theo_prstart_to_title
  187.     $game_temp.input_title_command = false
  188.   end
  189.  
  190. end
  191.  
  192. class Scene_Gameover < Scene_Base
  193.  
  194.   alias theo_prstart_goto_title goto_title
  195.   def goto_title
  196.     theo_prstart_goto_title
  197.     $game_temp.input_title_command = false
  198.   end
  199.  
  200. end
Advertisement
Add Comment
Please, Sign In to add comment