Make a game for Back to Simple Games
Thanks for making games for the site! This page explains what a game needs and how to send it. It is short, promise.
What your game needs
- One HTML file. Everything (HTML, CSS, JavaScript) can live in a single
index.html. If you also have pictures or sounds, that is fine too: put them in one folder next to the HTML file and use relative paths likeimg/player.png(notC:\Users\...and not/img/player.png). - No installs, no servers. It has to run by just opening the file in a browser. No Node, no PHP, no database. Libraries are OK if you copy the file into your folder.
- It runs inside a box (an iframe). The site shows your game in a frame with the rules next to it. So don't change
window.top, don't open pop-ups, and don't rely onalert()for important stuff. - A title. Put the game name in
<title>My Game</title>. We use it as the name on the site. - Rules. Write a few lines on how to play (a
.txtfile is perfect), or put a "How to play" heading with a list in your HTML and we will copy it from there.
Make it work on phones
- Add this line inside
<head>:<meta name="viewport" content="width=device-width,initial-scale=1"> - Make the game fit the box: use
width:100%orvw/vh, and scale your canvas to the window instead of a fixed 1200x800. - Fit the board on the screen. The site shows your game in a frame. A helper script sets a CSS variable
--bsg-stageto the visible height of that frame (it already subtracts the site header and phone toolbars, usingsvh/dvh). Size the board withmin()of width and height so the whole board and its main buttons fit at once, with no scrolling inside the frame, for example:
.board { width: min(100%, 460px, calc(var(--bsg-stage, 100svh) - 8rem)); aspect-ratio: 1; max-height: calc(var(--bsg-stage, 100svh) - 8rem); }
Change the 8rem to match your title, score and buttons. Rules sit beside or below the frame on the site, so you don't need to repeat them in the game. Extra lobby bits (chat, invite, QR) can go under the board — the page will scroll, but the board itself should stay fully on screen while playing. Don't set min-height: 100vh on body (it fights the frame and can add a scrollbar).
- Buttons should be big enough for a thumb (about 44px or more).
- Support taps as well as keys: use
pointerdown(works for mouse and touch), and add on-screen buttons if the game needs arrow keys. - Add
touch-action: noneon the game area so swiping doesn't scroll the page. - Test it in your browser's phone view (F12, then the phone icon).
How to send it
- Put your game in a folder (or just the one HTML file).
- Add your rules as
rules.txtif they are not in the HTML. - Zip the folder (right-click, Compress / Send to, Zipped folder) and email the zip as an attachment to the address you were given. A single HTML file can be attached as it is.
- Say in the email if it is single player or multiplayer, and how many players it needs.
We put it on a secret preview link first, test it, and send you the link. It only goes public on the home page once it is approved.
Multiplayer games
The site has a ready-made multiplayer system, so you don't need your own server. Add the script and it draws the whole lobby for you: nickname, online count, public rooms, private rooms with a code, Quick play, players list, chat, a Start button, and reconnecting if someone's Wi-Fi drops.
How it works: the player who made the room is the host. Other players send their moves to the host. The host checks each move, updates the game, and shares the new game state with everyone. If the host leaves, the next player becomes host and keeps going.
The main pieces:
BSG.lobby({...})shows the lobby and calls your functions when things happen.room.send(data)sends a move to the host (from a guest).room.setState(state)(host only) shares the game state with everyone. Everyone, including the host, gets it inonState.room.isHost,room.me(your player id),room.players(list of{id, name}),room.playerName(id).room.rematch()for a Play again button: the host's press starts a new round, a guest's press asks the host.
Here is a complete tiny game you can copy and change. Players take turns adding 1 or 2, and whoever reaches 10 wins:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Race to 10</title>
</head>
<body>
<div id="lobby"></div>
<div id="game" style="display:none">
<h1 id="count">0</h1>
<p id="status"></p>
<button onclick="move(1)">+1</button>
<button onclick="move(2)">+2</button>
<button id="again" onclick="room.rematch()">Play again</button>
</div>
<script src="/sdk/bsg-multiplayer.js"></script>
<script>
var room = null, state = null;
// Only the host runs this: check the move, update the game, share it.
function applyMove(playerId, n) {
if (!state || state.winner || state.order[state.turn] !== playerId) return;
if (n !== 1 && n !== 2) return;
state.count = Math.min(10, state.count + n);
if (state.count >= 10) state.winner = playerId;
else state.turn = (state.turn + 1) % state.order.length;
room.setState(state);
}
// Any player presses a button.
function move(n) {
if (!room || !state) return;
if (room.isHost) applyMove(room.me, n);
else room.send({ add: n });
}
function render() {
document.getElementById('game').style.display = state ? 'block' : 'none';
if (!state) return;
document.getElementById('count').textContent = state.count;
var turnId = state.order[state.turn];
document.getElementById('status').textContent = state.winner
? room.playerName(state.winner) + ' wins!'
: (turnId === room.me ? 'Your turn' : room.playerName(turnId) + "'s turn");
document.getElementById('again').style.display = state.winner ? '' : 'none';
}
BSG.lobby({
el: document.getElementById('lobby'),
onJoin: function (r) { room = r; state = r.started ? r.state : null; render(); },
onPlayers: function (r) { room = r; render(); },
onStart: function (r, info) {
room = r;
if (r.isHost && !info.resumed) {
r.setState({ order: r.players.map(function (p) { return p.id; }), turn: 0, count: 0, winner: null });
}
},
onState: function (s) { state = s; render(); },
onMessage: function (data, fromId) { if (room && room.isHost && data) applyMove(fromId, data.add); },
onLeave: function () { room = null; state = null; render(); }
});
</script>
</body>
</html>
Good to know:
- Multiplayer only works on the site (the lobby talks to our server), so you can't fully test it by double-clicking the file. Send it in and we will test it on the preview link with you.
- Keep the state small and simple (numbers, text, lists). Don't put functions in it.
- Players who join after the game started can watch. They get the latest state in
onJoin. - Want a turn clock? There is an optional timer:
var timer = BSG.turnTimer({ seconds: 20, onTimeout: function () { if (room.isHost) { / skip the turn / } } });then calltimer.sync(state.turn + ':' + state.count)inonState. It is off unless you use it. - A bigger example is Drop Four (four in a row), which is already built on this system.
Scores and leaderboards
The site can keep a weekly and all-time leaderboard for a game. Players use a nickname (no accounts). A private id stays in their browser so two people with the same nickname don't get mixed up.
Multiplayer games are recorded automatically from the room on our server, once a finished game between two different players is checked. You don't call anything. Quick quits and games against yourself don't count. Drop Four works this way already.
Single-player games send a score with BSG.reportScore. Include /sdk/bsg-score.js (or rely on the site adding it) and, for a puzzle, ask the server for the puzzle first so it can check the solve:
<script src="/sdk/bsg-score.js"></script>
<script>
// 1. Get a puzzle the server knows about.
BSG.newPuzzle({ game: 'lights-out', size: 5 }).then(function (p) {
// p.seed, p.size, p.grid — show p.grid, remember p.seed
});
// 2. When the player solves it, send the move list (not just the number).
BSG.reportScore({
game: 'lights-out',
name: BSG.getName() || 'Alex',
seed: seed,
size: 5,
moves: [{ r: 0, c: 1 }, { r: 2, c: 2 }],
time: Date.now() - startedAt
}).then(function (r) {
if (r.ok) { /* saved */ }
});
</script>
Useful helpers: BSG.clientId(), BSG.getName(), BSG.setName(n) (max 16 characters). Keep nicknames polite; rude ones are rejected.
A new game is not added to the public leaderboard until we have a way to check its scores on the server. Until then, reportScore returns an error and nothing is stored. Tell us how your scoring works when you send the game.
Each game page shows a compact leaderboard under the game, and all boards are listed at /leaderboards.
Questions?
Just reply to the email thread. Have fun making games!