Skip to main content
Engineering LibreTexts

8.5: Setting up Timing Constants for Holding Down Keys

  • Page ID
    13608
  • MOVESIDEWAYSFREQ = 0.15
    MOVEDOWNFREQ = 0.1
    

    Every time the player pushes the left or right arrow key down, the falling piece should move one box over to the left or right, respectively. However, the player can also hold down the left or right arrow key to keep moving the falling piece. The MOVESIDEWAYSFREQ constant will set it so that every 0.15 seconds that passes with the left or right arrow key held down, the piece will move another space over.

    The MOVEDOWNFREQ constant is the same thing except it tells how frequently the piece drops by one box while the player has the down arrow key held down.

    • Was this article helpful?