Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Stop F12 from resetting your game
#1
Here is a rather useful snippet I just cooked up.
This prevents the F12 key from resetting the game.
For some reason pressing the F12 key now seems to speed up the game in many cases and in other pauses the game.

Code:
#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception
  
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_removal_update)
      alias_method(:zeriab_f12_removal_update, :update)
      alias_method(:zeriab_f12_removal_transition, :transition)
    end
    def update(*args)
      begin
        zeriab_f12_removal_update(*args)
      rescue Reset
        # Do nothing
      end
    end
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_removal_transition(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
    end
  end
end
For an extreme example of the speed up issue I mentioned here is a picture:
[Image: speedboostlx8.png]

I don't know whether it actually went with 410 FPS or if something broke.

If the player press F12 during a transition the transition will reset and start again.
If F12 is kept pressed the game will feel like it has been paused. The FPS registered will typically be registered as higher although game playing will not change. Nor will it if it's Graphics.update being cancelled. The shown timer will however run faster.
Here is a snippet where it feels like the game simply pauses when pressing F12, if that is what one prefer:

Code:
#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception
  
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_removal_update)
      alias_method(:zeriab_f12_removal_update, :update)
      alias_method(:zeriab_f12_removal_transition, :transition)
    end
    def update(*args)
      done = false
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_removal_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
    end
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_removal_transition(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
    end
  end
end
*hugs*
- Zeriab
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Name Game Switch & Variable RG kyonides 0 594 06-27-2023, 09:17 PM
Last Post: kyonides
Photo  Map Tileset Changer during the game Narzew 1 5,784 05-06-2013, 09:18 PM
Last Post: Narzew
   DerVVulfman's Game Data Sneak DerVVulfman 2 6,697 04-04-2013, 03:50 AM
Last Post: DerVVulfman
   Mr.Mo ABS Game Log Window JayRay 0 4,798 10-30-2012, 06:54 AM
Last Post: JayRay
   Limit Breaker - breaks game limits Narzew 1 5,775 10-09-2012, 10:35 AM
Last Post: MetalRenard
   In game Tone change ! Grimimi 1 4,736 10-09-2012, 01:31 AM
Last Post: Samven
   1 Save Slot / AutoLoad Saved Game kyonides 1 5,993 07-09-2010, 08:38 AM
Last Post: Kread-EX
   Arcade Game System WIP computerwizoo7 0 4,743 03-25-2010, 01:20 PM
Last Post: computerwizoo7
   Card Game Data Structure Trickster 5 10,067 12-09-2009, 06:38 PM
Last Post: Trickster
   [Unsupported] Game Strings (Streamline dialogue!) PK8 3 8,328 09-15-2009, 11:28 PM
Last Post: Wyatt



Users browsing this thread: