Runtime View
The "Life of a Frame": A Story of a Tick
Instead of a simple list of steps, let's walk through what happens in the ~16.6 milliseconds of a single game frame:
- "What do they want to do?" (Input): We check the
Keystate for humans and let theAutopilotthink for the bots. This sets the intended velocity and rotation for every tank. - "Where would they be?" (Physics Simulation): The engine calculates the next position. It checks: "If this tank moves 5 pixels, does it hit a wall?" If yes, the custom physics engine slides the tank along the wall or stops it.
- "Did something die?" (Collision Resolution): We check if any bullet is close enough to a tank to trigger a
kill(). If so, scores are updated in theGameStore, and the tank is scheduled for respawn. - "Clean up the mess" (Maintenance): We remove bullets that have lived too long and particles that have faded out. We re-sort everything into the Grid Tiles so the next frame's physics checks are fast.
- "Paint the result" (Rendering): Finally, the engine tells the
Canvas: "Everyone is in their final position for this frame. Show the user." The canvas clears, draws the map, and then draws each object.
Power-up Spawning
Power-ups are spawned at random intervals by the Game controller at valid (empty) map locations, ensuring the game state remains dynamic.