Orbit Game Suite

Interactive Gaming Suite
Back to Gateway

1. Introduction & Purpose

What is it?

Orbit is a real-time, multiplayer web-based gaming suite. It allows two players to connect seamlessly and play a variety of minigames together, ranging from cooperative challenges to competitive duels.

What is it for?

Originally designed as a cooperative "Valentine's Experience", the suite serves as a fun, interactive way for two people to connect over the web and play simple, engaging games that require teamwork and coordination.

How does it work? (High-Level Overview)

The game is completely browser-based and does not require any downloads or complex server installations to play. One player (the "Host") visits the website and creates a room, which generates a short Room Code. The other player (the "Client") visits the same website, enters that code, and connects.

Once connected, the Host can choose which game to play from a central lobby. The games are visually rendered using 3D graphics (via a library called Three.js) directly in the browser. The entire system is built on modern web technologies, specifically using WebRTC (via PeerJS) for direct, low-latency communication between the two players' devices.

---

2. Architecture Overview: The "Shell" System

The application uses what is called a "Shell" architecture.

When players connect to each other, maintaining that connection is crucial. If a player navigates to a new web page (e.g., clicking a link to go from the lobby to a specific game), the browser drops the current connection, and they would have to reconnect.

To solve this, Orbit uses index.html as a persistent "Shell."

1. The shell establishes and maintains the PeerJS WebRTC connection between the two players.

2. When a game is selected, the shell does *not* navigate to a new page. Instead, it creates an invisible "window within the window" called an iframe and loads the specific game file (e.g., tunnel.html) into it.

3. The shell overlays this iframe on top of the lobby, making it look like the game has started.

4. When the game ends, the shell simply destroys or hides the iframe and shows the lobby again, all without ever dropping the connection.

Communication (postMessage):

Because the network connection lives in the Shell (index.html) but the game logic lives in the iframe (tunnel.html), they need to talk to each other. They do this using the browser's postMessage API.

---

3. Network & Requests Explained

There are three main types of network requests/communication happening in Orbit:

A. Room Generation (Cloudflare Worker - `worker.js`)

B. Signalling (PeerJS Server)

C. Game State & Commands (PeerJS DataChannel)

---

4. Detailed File Breakdown

`index.html` (The Shell & Lobby)

`worker.js` (The Cloudflare API)

`tunnel.html` (Tunnel Run)

`shooter.html` (Space Duel)

`grid.html` (Grid Dodge)

`defense.html` (Core Defense)

`tictactoe.html` (Tic-Tac-Toe)

---

5. Deployment Guide

A. Deploying the Game (Frontend)

The game is completely static (HTML, CSS, JS) and can be hosted anywhere.

1. GitHub Pages (Recommended):

B. Deploying the API (Cloudflare Worker)

*Note: This is optional as index.html currently handles rooms locally, but is required if you want to use the server-side room generation.*

1. Log in to the Cloudflare Dashboard.

2. Go to "Workers & Pages" -> "Create Worker".

3. Name it (e.g., orbit-api).

4. Click "Edit Code" and paste the contents of worker.js.

5. Deploy. You will receive a URL (e.g., https://orbit-api.[your-username].workers.dev).

6. Update index.html to fetch from this URL instead of generating locally.

Visit Live Platform