Advertisement
LiTTleDRAgo

[RGSS/2/3] Press Any Key Script

Oct 29th, 2012
638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.44 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Press Any Key Script
  3. # Version 1.02
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. ($imported ||= {})[:press_any_key] = 1.02
  7. #==============================================================================
  8. # ** Window_Command
  9. #------------------------------------------------------------------------------
  10. #  This window deals with general command choices.
  11. #==============================================================================
  12.  
  13. class Window_Command < Window_Selectable
  14.  
  15.   VX         = defined? Window_ActorCommand
  16.   VXA        = defined? Window_BattleActor
  17.   FONTNAME   = ['Calibri','Arial',Font.default_name].flatten
  18.   FONTSIZE   = 30
  19.   FONTBOLD   = false
  20.   FONTITALIC = true
  21.   TEXT       = 'Press Any Button'
  22.   POS        = [0,330]   # Position X and Y
  23.   ALIGN      = 1         # 0 = left, 1 = center, 2 = right
  24.   WAIT       = 10        # Wait time from each changing color
  25.  
  26.  
  27.   $@ || alias_method(:init_drgprs, :initialize)
  28.   define_method(:scene) { VXA ? SceneManager.scene : $scene }
  29.  
  30.   def initialize(*args)
  31.     scene.is_a?(Scene_Title) && press_any_button
  32.     init_drgprs(*args)
  33.   end
  34.  
  35.   def create_press_any
  36.     @spr = [Sprite.new,Sprite.new]
  37.     @spr[0].bitmap = s = Graphics.respond_to?(:snap_to_bitmap) ?
  38.                      Graphics.snap_to_bitmap : Bitmap.new(640,480)
  39.     s.font.size   = FONTSIZE
  40.     s.font.name   = FONTNAME
  41.     s.font.bold   = FONTBOLD
  42.     s.font.italic = FONTITALIC
  43.     s.draw_text(POS[0], POS[1]-230, s.width, s.height,[s.clear] && TEXT, ALIGN)
  44.     @spr[1].bitmap = z = @spr[0].bitmap.dup
  45.     if s.respond_to?(:draw_edging_text) && [z.clear]      
  46.       z.draw_edging_text(POS[0], POS[1]-230, s.width, s.height, TEXT, ALIGN)
  47.     end
  48.     @spr.each_with_index {|s,i| s.z = i == 0 ? 100 : 70 }
  49.   end
  50.    
  51.   def update_input_press_basic
  52.     return press_any_key if $imported[:drg_core_engine]
  53.     return true if Input.trigger?(Input::A)
  54.     return true if Input.trigger?(Input::B)
  55.     return true if Input.trigger?(Input::C)
  56.     return true if Input.trigger?(Input::X)
  57.     return true if Input.trigger?(Input::Y)
  58.     return true if Input.trigger?(Input::Z)
  59.     return true if Input.trigger?(Input::L)
  60.     return true if Input.trigger?(Input::R)
  61.   end
  62.  
  63.   def press_any_button
  64.     [Graphics.transition(0), play_title_se]
  65.     [create_press_any, update_press_any]
  66.   end
  67.  
  68.   def play_title_se
  69.     return scene.play_title_music if VX
  70.     $game_system.bgm_play($data_system.title_bgm)
  71.   end
  72.  
  73.   def update_press_any
  74.     until update_input_press_basic
  75.       update_change_color && [Graphics,Input].each {|s| s.update }
  76.     end
  77.     sound_play_ok
  78.     @spr[0].bitmap.blt(0,0,s = [@spr[0].bitmap.clear] && @spr[1].bitmap,s.rect)
  79.     while (@spr[0].opacity > 0 || @spr[1].opacity > 0)
  80.       @spr.each_with_index {|s,i| s.x = i == 0 ? s.x - 2 : s.x + 2 }
  81.       @spr.each_with_index {|s,i| s.opacity -= 3 }
  82.       [Graphics,Input].each {|s| s.update }
  83.     end
  84.     @spr.each {|s| [s.bitmap.dispose, s.dispose] }.clear
  85.   end
  86.   def sound_play_ok
  87.     return VXA ? Sound.play_ok : Sound.play_decision if VX
  88.     $game_system.se_play($data_system.decision_se)  
  89.   end
  90.  
  91.   def update_change_color
  92.     @item_max = ((@item_max || 0) + 1) % 240
  93.     rgb = [rand(255),rand(255),rand(255)]
  94.     [@item_max % WAIT == 0 && @spr[0].flash(Color.new(*rgb),1)]
  95.   end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement