If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
You may edit your post above.
Generally break the process down into stages:
-
gather user intent
-
process user intent and decide how to:
-
change state of game
Step 3 above will often involve adjusting the UI state to reflect the change, such as graying it out for a cooldown period.
Cooldown timers, gun bullet intervals, shot spacing, rate of fire:
GunHeat (gunheat) spawning shooting rate of fire: