Cooldowns in Video Games: How a Tank Game Times Every Action
You press the dash button, your tank shoots forward, and then you press it again and nothing happens. That pause is a cooldown. This post explains cooldowns in video games: what they are, how they are built in code, and how two browser tank games use them on the fire button, the dash and the shield. Every number here comes from the games' own code.
What are cooldowns in video games?
A cooldown is the wait after you use an action before you can use it again. The Wikipedia glossary of video game terms defines it as the minimum length of time the player needs to wait after using an ability before they can use it again. The same entry says this is commonly done for game balance, so that less powerful abilities stay worth using.
Think of it as a rule about time, attached to one button. You use the action, a timer starts, and the action stays locked until the timer runs out. Then it is ready again.
That small rule changes how you play. When a strong move is always ready, you press it every second and the weaker moves gather dust. When the strong move has a wait, you have to decide when it is worth spending.
How a cooldown works in code
Under the hood, a cooldown is usually one number per action: the time left before it is ready. The game does three things with it.
- Start it. When you use the action, the game sets the number to the full wait, for example 1.5 seconds.
- Count it down. Every frame, the game subtracts the time that passed since the last frame.
- Check it. When you press the button, the game lets the action happen only if the number has reached zero.
That is the whole pattern. In Tank City Zero Day, the dash check reads, in plain words, "if dash was pressed and the dash timer is at zero or below, dash and set the timer to the full recharge". The fire button works the same way with its own timer.
Because the timer is just a number, the game can also draw it. A bar that fills from empty to full is simply "time passed divided by the full wait". You will see that in the next section.
The dash cooldown in Zero Day
In Tank City Zero Day, your tank can dash: a quick burst of speed. The dash itself lasts 0.2 seconds.
The recharge starts at the same moment the dash starts, not when it ends. So the 0.2 seconds of dashing sit inside the recharge, and the time you actually wait after the dash finishes is the recharge minus 0.2 seconds.
The side panel shows a DASH bar. It is drawn from the timer: one minus the time left divided by the full recharge. Right after a dash the bar is empty, and it grows as the timer runs down.

The 0.2 second dash sits inside the recharge, which gets shorter at each Overclock level.
Worked example: dash timings per Overclock level
Zero Day has an upgrade called Overclock. Its card says "Move faster, dash more often.", and the game uses the name to teach the idea behind it: overclocking runs a chip faster than its rated speed. Overclock goes up to level 2.
The rule in the code is: recharge = 1.5 x (1 - 0.3 x Overclock level). Work it through for each level:
- Level 0: 1.5 x (1 - 0) = 1.5 seconds. Dash 0.2 s, then wait 1.3 s.
- Level 1: 1.5 x (1 - 0.3) = 1.5 x 0.7 = 1.05 seconds. Dash 0.2 s, then wait 0.85 s.
- Level 2: 1.5 x (1 - 0.6) = 1.5 x 0.4 = 0.6 seconds. Dash 0.2 s, then wait 0.4 s.
So two Overclock levels cut the dash recharge by 60 percent, from 1.5 seconds to 0.6. If you hold the dash button and dash the instant it is ready, you go from one dash every 1.5 seconds to one every 0.6 seconds, which is 2.5 times as many dashes.
Fire rate is a cooldown too
You might not call it a cooldown, but the time between shots is one. In Zero Day, when you hold fire, the game shoots as soon as the fire timer is at zero and then resets it to the fire gap. The Cache upgrade shortens that gap. The rule is 0.3 x 0.75 to the power of the Cache level, and Cache goes up to level 3:
- Level 0: 0.3 seconds between shots, about 3.3 shots a second.
- Level 1: 0.225 seconds, about 4.4 shots a second.
- Level 2: about 0.169 seconds, about 5.9 shots a second.
- Level 3: about 0.127 seconds, about 7.9 shots a second.
Each level multiplies the gap by 0.75, so each level cuts it by a quarter of what it was, not by a fixed amount. That is why the first level feels like the biggest jump in seconds.
The first game, Tank City Reboot, handles fire differently. A fresh press of fire shoots at once. Holding the button repeats, but only 0.25 seconds after your last shot. On top of that, no new shot leaves while you already have your most shots on screen, so the next shot waits until one of yours is gone. Tapping fast is rewarded, and the screen limit stops you from filling the map with shots.
Enemy tanks in the first game have their own fire timer. After each shot an enemy waits a random time between 0.6 and 1.8 seconds, divided by the game's speed multiplier. The random wait makes them harder to read than a fixed beat would.
The shield recharge in Zero Day
A cooldown does not have to sit on a button. The Zero Day Sandbox upgrade gives you a shield that stops one hit, then recharges on its own: 12 seconds at level 1, and 8 seconds at level 2. The game uses the name to teach a real idea, since a sandbox runs untrusted code where it cannot touch the rest of the system.
Here the cooldown works for you rather than against you. You do not press anything. You just know that after the shield takes a hit, you are open for a while, so you play more carefully until it comes back. Our post on shields in action games covers the one-hit and recharging kinds in more detail.
A short window of safety is a close cousin of the cooldown. If you want to see how games time that window, read what invincibility frames are. And if you want to see how the game decides which screen you are on while all these timers run, the post on the game state machine walks through it.
Frequently asked questions
What does cooldown mean in a game?
It is the wait after you use an action before you can use it again. The action stays locked until a timer runs out.
Why do games use cooldowns?
The Wikipedia glossary says cooldowns are commonly used for game balance, so less powerful abilities stay worth using. A strong move with a wait has to be spent with care.
How long is the dash cooldown in Zero Day?
It is 1.5 seconds, 1.05 seconds at Overclock level 1 and 0.6 seconds at level 2. The 0.2 second dash counts inside that time.
Is the time between shots a cooldown?
Yes. In Zero Day holding fire shoots every 0.3 seconds, and each Cache level multiplies that gap by 0.75.
Get started
The best way to feel a cooldown is to watch the DASH bar refill while you play. Open Tank City Reboot in your browser, play Zero Day, and try dashing before and after you take Overclock. Playing never needs an account. The game teaches the idea behind each name as you play; it is a game, not a course.
Comments
No comments yet.
Sign in or make an account to comment.