The page itself: the HTML shell, the CSS that makes it full-screen, and the canvas setup that gives the game a fixed 480×640 playfield on any screen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Glidepath — AI & Me Studios</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; background:#050816; overflow:hidden; touch-action:none; overscroll-behavior:none; }
body { font-family:"Segoe UI", system-ui, -apple-system, sans-serif; color:#e8ecff; }
#wrap { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; }
canvas { display:block; touch-action:none; user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }
</style>
</head>
<body>
<div id="wrap"><canvas id="game"></canvas></div>
<script>
"use strict";
/* Glidepath — an AI & Me Studios arcade game. Original code and art.
Tap / click / Space to thrust. Guide the rocket down its glidepath (the descent path to the pad) and land it on the pad. Pad point zones: center PERFECT +500, mid GREAT +250, outer GOOD +100. */
const cv = document.getElementById('game');
const ctx = cv.getContext('2d');
// Logical playfield (portrait, phone-first).
const W = 480, H = 640;
let scale = 1, dpr = 1;
function resize() {
dpr = Math.min(window.devicePixelRatio || 1, 2);
const aw = window.innerWidth, ah = window.innerHeight;
scale = Math.min(aw / W, ah / H);
const w = Math.round(W * scale * dpr), h = Math.round(H * scale * dpr);
if (w === lastRW && h === lastRH) return;
lastRW = w; lastRH = h;
cv.style.width = (W * scale) + 'px';
cv.style.height = (H * scale) + 'px';
cv.width = w;
cv.height = h;
}
let lastRW = 0, lastRH = 0;
window.addEventListener('resize', resize);
resize();
/* Same first-load race as Galactic Zone: the iframe can load while its view
is hidden, so the first size read comes back ~0. Re-fit periodically and
when the tab becomes visible so the game recovers within half a second. */
setInterval(resize, 500);
document.addEventListener('visibilitychange', () => { if (!document.hidden) resize(); });This file is the top of the game: the HTML page, the CSS that makes it full-screen, and the JavaScript that sets up the canvas and the fixed logical playfield everything else is measured in.
The page is a plain HTML document. The <head> sets the character set and a viewport tag that locks the page to the device width, disables zooming and double-tap zoom (maximum-scale=1, user-scalable=no). That matters because this is a tap game — you don't want the browser zooming when the player taps fast.
The <body> holds one thing: a <div id="wrap"> containing a single <canvas id="game"> element. The canvas is where every pixel of the game is drawn. There are no images, no DOM game elements — just this one canvas.
const cv = document.getElementById('game');
const ctx = cv.getContext('2d');
cv is the canvas element, ctx is its 2D drawing context. Every draw call in the whole game goes through ctx.
const W = 480, H = 640;
This is the key idea: the game is designed in a FIXED logical size, 480 wide by 640 tall (portrait, phone-first). All positions, speeds, and sizes in the code are in these units. The real screen can be any size; resize() scales this logical playfield to fit it.
function resize() {
dpr = Math.min(window.devicePixelRatio || 1, 2);
const aw = window.innerWidth, ah = window.innerHeight;
scale = Math.min(aw / W, ah / H);
...
}
The comment explains a real bug: the game can load inside an iframe while its view is hidden, so the first size read comes back ~0. The fix is belt and suspenders — resize() runs every 500ms on a timer (setInterval(resize, 500)) and again whenever the tab becomes visible (visibilitychange). So the game recovers within half a second of being shown. The same pattern is in Galactic Zone.