Advertisement
M3rein

Better Fast-forward Mode

Oct 21st, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.16 KB | None | 0 0
  1. #==============================================================================#
  2. #                         Better Fast-forward Mode                             #
  3. #                                   v1.0                                       #
  4. #                                                                              #
  5. #                                 by Marin                                     #
  6. #==============================================================================#
  7. #                                   Usage                                      #
  8. #                                                                              #
  9. # MAX_GAME_SPEED is the fastest the user can make the game. It represents the  #
  10. #                   amount of frames that will be skipped.                     #
  11. #                $GameSpeed is the current level of speed up.                  #
  12. #   Should you want to change that manually, you can do like $GameSpeed = 1    #
  13. #                    Protip: Don't ever set it to 0. Ever.                     #
  14. #                                                                              #
  15. # If you don't want the user to be able to speed up at certain points, you can #
  16. #                use "pbDisallowSpeedup" and "pbAllowSpeedup".                 #
  17. #==============================================================================#
  18.  
  19. # The fastest the user can make the game.
  20. MAX_GAME_SPEED = 3
  21.  
  22.  
  23. def pbAllowSpeedup
  24.   $CanToggle = true
  25. end
  26.  
  27. def pbDisallowSpeedup
  28.   $CanToggle = false
  29. end
  30.  
  31. # Default game speed.
  32. $GameSpeed = 1
  33.  
  34. $frame = 0
  35. $CanToggle = true
  36. module Graphics
  37.   class << Graphics
  38.     alias fast_forward_update update
  39.   end
  40.  
  41.   def self.update
  42.     if $CanToggle && Input.trigger?(Input::F)
  43.       $GameSpeed += 1
  44.       $GameSpeed = 1 if $GameSpeed > MAX_GAME_SPEED
  45.     end
  46.     $frame += 1
  47.     return unless $frame % $GameSpeed == 0
  48.     fast_forward_update
  49.     $frame = 0
  50.   end
  51. end
  52.  
  53. module Input
  54.   class << Input
  55.     alias fast_forward_button_to_key buttonToKey
  56.   end
  57.  
  58.   F = 50
  59.  
  60.   def self.buttonToKey(btn)
  61.     return [0x46] if btn == Input::F
  62.     fast_forward_button_to_key(btn)
  63.   end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement