Sure, here's an example of a simple tower defense game implemented as a single HTML file using JavaScript:
This example sets up a simple tower defense game where the player controls a blue square using arrow keys, trying to avoid collision with a red enemy square. The game canvas is rendered using the HTML5 Canvas element, and the game state is updated in the `updateCanvas` function which is called recursively using `requestAnimationFrame` until the game is over.