You can build a Great Fire of London interactive game yourself in a browser using nothing more than HTML, CSS and JavaScript, and it works best as a simple map-based survival-and-spread simulation: the player moves a 1666 Londoner between streets, chooses whether to fight the fire or flee, and watches the flames spread across a grid of buildings. Nothing needs installing first beyond a plain text editor and a browser; a free code editor such as Visual Studio Code makes the work easier but is optional. The steps below take you from an empty file to a playable game, and they assume you are building for a modern desktop browser.
What You'll Need
- A plain text editor (Notepad, TextEdit, or a free code editor such as Visual Studio Code).
- A modern browser (Chrome, Edge, Firefox or Safari) to test the game.
- Three files in one folder:
index.html,style.cssandgame.js. - Optional: a few small images or simple coloured squares for buildings; emoji or CSS colours work fine and avoid licensing questions.
- Optional: a local web server if you later add images loaded by script; opening the HTML file directly is enough for the version below.
Step-by-Step
- Set up the folder and files. Create a folder called
great-fire-game. Inside it, make the three files listed above. Inindex.html, write the standard page skeleton with a<link>tostyle.cssin the head and a<script src="game.js"></script>just before the closing body tag. Add an empty<div id="board"></div>and a<p id="status"></p>for messages. - Decide the grid. A 10 by 10 grid is a good size: 100 cells, each representing a building or street segment. In
game.js, create a constant for the number of rows and columns, and build the board with two nested loops, creating a<div>per cell and giving each one adata-rowanddata-colattribute so you can find it later. Append each cell to the board element. - Style the board. In
style.css, set#boardtodisplay: gridwithgrid-template-columns: repeat(10, 40px)and a small gap. Give each cell a fixed width and height, a border and a background colour. Use classes such as.building,.fire,.burntand.playerso JavaScript can change a cell's appearance by swapping classes rather than writing inline styles. - Create the game state. In
game.js, keep a two-dimensional array (or a flat array with an index formula) holding one value per cell:building,fire,burntorempty. Also store the player's row and column, a turn counter and agameOverflag. Write arender()function that loops over the state and applies the matching class to each cell, then call it once at start-up. - Place the starting fire. Choose a cell to represent Pudding Lane and set it to
fire. Place the player a few cells away. Because the real fire began in a bakery on Pudding Lane in September 1666, naming the starting cell accordingly gives the game its historical hook without needing any external data. - Add keyboard movement. Attach a
keydownlistener to the document. Map the arrow keys (and optionally W, A, S and D) to changes in the player's row and column. Before moving, check the target is inside the grid and is not on fire; if it is, refuse the move and show a message in the status paragraph. After a successful move, call your turn function. - Write the fire-spread rule. On each turn, loop over every cell. For each burning cell, look at its four orthogonal neighbours (up, down, left, right). Give each neighbouring building a chance to catch fire, for example a one-in-three chance using
Math.random(). Collect the changes first and apply them after the loop, otherwise a cell that catches fire this turn can immediately spread again in the same turn and the fire will run away. - Burn out old cells. A cell that has been on fire for a set number of turns should become
burntand stop spreading. Store a small counter per cell, increment it each turn while the cell burns, and convert it once it passes your threshold. This gives the fire a moving front rather than an instant map-wide blaze. - Add a win and lose condition. Losing is simple: if the player's cell catches fire, or the player is surrounded by fire and cannot move, set
gameOverand show a message. Winning can be reaching a designated safe cell at the edge of the map, or surviving a fixed number of turns. Display the outcome in the status paragraph and stop accepting movement input. - Add a restart control. Put a
<button id="restart">in the HTML and attach a click listener that resets the state array, the turn counter, the player position and thegameOverflag, then callsrender(). Without this, every test run means reloading the page. - Layer in historical flavour. Name a few cells after real streets and landmarks of the period, and add a short line of explanatory text that appears when the player reaches them. Keep the text factual and brief; the game is an introduction, not a history lesson, and you should avoid inventing dates, casualty figures or quotes you cannot verify.
- Test and tune. Play ten or so rounds. If the fire always wins in three turns, lower the spread chance; if it never spreads, raise it. Adjust the burnout threshold and the grid size until a round lasts roughly one to three minutes, which suits a classroom or a quick browser break.
Common Mistakes
The most frequent bug is spreading fire while looping over the same array you are changing, which makes the fire jump several cells per turn; always collect changes and apply them afterwards. A second common error is forgetting to check the grid edges, so a neighbour lookup at row zero reads a negative index and either crashes or wraps around. Third, many builds update the state but never call render(), so the screen looks frozen. Finally, hard-coding pixel sizes without a fixed cell size in CSS makes the grid collapse or overlap on different screens.
Tips
Keep all game rules in one small function so you can change difficulty in a single place. Use CSS classes rather than inline styles so colours and animations stay in the stylesheet. Add a simple transition on the cell background so fire appears to flicker. If you want the game to work on phones, add on-screen arrow buttons and listen for touch events, because a keyboard-only build is unusable on mobile. Test in at least two browsers before sharing the file.
Troubleshooting
If nothing appears on screen, open the browser's developer console (usually F12) and read the first error; a mistyped file path in the <script> tag is the usual cause. If the board renders but keys do nothing, confirm the listener is attached to document and not to a cell that never receives focus. If the fire spreads instantly across the whole map, you are almost certainly modifying the state during the loop. If the player can walk onto fire, check the order of your movement validation. If the game freezes after restarting, make sure the restart handler rebuilds the state array rather than reusing the old one.
Frequently Asked Questions
Do I need to install anything to make this game?
No. A text editor and a browser are enough; the game runs from local files without a server or framework.
Can I use real images of the 1666 streets?
Only images you have the right to use. Simple coloured squares and emoji avoid licensing problems entirely.
How do I make the game harder or easier?
Change the fire-spread probability and the burnout threshold; a higher chance and a longer burnout make it harder.
Will it work on a phone?
Not with keyboard controls alone. Add on-screen buttons and touch listeners if mobile play matters to you.