Play Packet Defense
A colorful tower defense strategy game built with plain JavaScript and canvas. Place defenses to stop malicious packets before they reach your server, and survive eight waves.
This is a real, playable strategy game, not a screenshot. Packets stream along the wire toward your server, and you build defenses to destroy them and earn coins for more. It is built with no library, just a route, some targeting maths, and a render loop, which makes it a clear example of how several systems run together. After you play, the sections below show how it works.
How to play
Malicious packets enter on the left and follow the wire toward your server on the right. Your job is to stop them. Pick a defense, then tap an empty tile next to the path to build it, and it will automatically fire at packets in range. Every packet you destroy pays out coins to build more. A packet that reaches the server costs you a life, and if your lives run out the server is breached. Clear all 8 waves to win. The Scanner is cheap and fast for thinning crowds, the Firewall is pricier but hits hard, so mix them and cover the long straights and corners.
How this game is built
A tower defense ties together routing, targeting, timing, and economy, all on one loop.
The path and waypoints
The wire is a list of waypoints, and each packet steers toward the next one until it reaches the server. Following a route like this is a compact movement system the game loop advances every frame.
Towers picking a target
On each cooldown a tower measures the distance to every packet and fires at the one in range that is furthest along the wire, the same range and distance maths behind collision detection.
Waves, coins, and lives
A wave spawns a set number of packets on a timer, kills pay coins, leaks cost lives, and clearing a wave pays a bonus. All of it is plain values the screen reflects, the core of game state management.
Placing defenses from a tap
A tap is turned into a grid cell, checked against the path and existing towers, and charged against your coins. That tap to action flow is the input idea in handling game input.
Why this models real systems
A stream of packets heading for a server, defenses that inspect and filter them, and limited resources to spend is not far from how real networks and services are protected. Systems handle a flow of incoming events, apply layers of checks, and prioritise what matters under load, the same shape as the patterns in event streaming and realtime systems. Playing defender makes that flow tangible.
Frequently asked questions
How do I play Packet Defense?
Choose a defense at the bottom, then tap an empty tile beside the wire to build it. Defenses fire automatically. Destroy packets to earn coins, keep packets off your server, and clear all 8 waves.
What is the difference between the two defenses?
The Scanner is cheap and fires quickly with low damage, good against many weak packets. The Firewall costs more and fires slower but hits much harder, good for tougher packets later on.
How do I earn more coins?
You earn coins for every packet you destroy and a bonus each time you clear a wave. Spend wisely between waves to expand your defenses before the next one arrives.
How does this relate to real programming?
It models a stream of incoming events being filtered by layered defenses under a resource budget, which mirrors how real services inspect traffic and prioritise work when load rises.
Want the engineering behind streams of events?
See how systems process a continuous flow of data.
Read: Event Streaming Architecture →