๐จ My First Browser Game ยท Episode 6 of 6 ยท See All Episodes
๐ฒ Episode 6 ยท Series Finale ยท Extends the Episode 5 Builder
Beyond the Builder! Platformer Part 2
You built a platformer in the Episode 5 live builder, now take the training wheels off. Write the whole thing yourself in one file, then add double jump, wall slide, a parallax camera and your own level format.
ctx.translate inside save/restore shifts EVERYTHING you draw, it is sf::View for the browser. No per-draw offsets needed.
โจ๏ธ
Code Challenge
+20 XP
Draw the world through a translated camera:
platformer2.html
ctx.();
ctx.translate(, 0);
drawWorld();
ctx.();
๐ก Hint: Snapshot the canvas state, shift the origin left by the camera, draw, then restore the state.
๐ง
Knowledge Check
+15 XP
Clouds at 0.1ร scroll look further away than hills at 0.3ร becauseโฆ
AThey are drawn smaller
BParallax: in real life distant objects shift less as you move, the brain decodes speed as depth
CCanvas blurs them
5
๐บ๏ธ
Levels as Text
Design levels with ASCII strings
Locked
๐ฏ
Goal for this step
Define your world as strings and parse them into platforms.
1A level is an array of strings: # ground, = platform, ^ spike, o coin, E enemy, F flag, each char one 40px tile.
2A parse function walks rows/columns and fills your arrays (platforms, spikes, coins, enemies, flag).
3Now design in your editor: type a mountain! (This is Python Breakoutโs pattern idea, expanded.)
4Adjacent # cells can merge into wide rects for performance, optional polish.
platformer2.html
const LEVEL = [
" F ",
" ==== ",
" o E ",
" o ===== ===== ^^ ",
" ==== ====== ",
" ^^ E ",
"##############################",
];
function parse(level) {
for (let r = 0; r < level.length; r++)
for (let c = 0; c < level[r].length; c++) {
const ch = level[r][c];
const x = c * 40, y = r * 40;
if (ch === "#" || ch === "=")
platforms.push({ x: x, y: y, w: 40, h: 40 });
if (ch === "o") coins.push({ x: x + 11, y: y + 11 });
if (ch === "^") spikes.push({ x: x, y: y + 20 });
if (ch === "E") enemies.push(makeEnemy(x, y));
if (ch === "F") flag = { x: x, y: y };
}
}
โ๏ธ
Fill in the Blanks
+15 XP
Each character maps to one px tile. The parser turns text into the platforms, coins, spikes, enemies and arrays.
๐ง
Knowledge Check
+15 XP
The biggest win of ASCII levels isโฆ
ASmaller files
BYou SEE the level shape in the code and can edit it like a drawing, design speed goes way up
CFaster collision
6
๐
Enemies, Timer & The Wrap
Stomp enemies, race the clock, finish the series
Locked
๐ฏ
Goal for this step
Wire in patrol enemies, a speedrun timer, and complete the series.
1Patrol enemies + stomp: your Python Part 2 logic, JavaScript spelling, you can port it without help now (that is the test!).
2Speedrun timer: performance.now() at level start; show elapsed; save the best per level in localStorage.
3Series review, you have used: canvas & DOM, rAF, events, arrays & objects, algorithms (Fisher-Yates!), localStorage, touch input, parallax and a level format.
4You can now build almost ANY 2D idea in a single HTML file people open with a click. That is a superpower. Use it. ๐
๐ก Hint: The browserโs precise timer returns milliseconds, divide to get seconds, one decimal place.
๐ง
Knowledge Check
+15 XP
Six episodes of browser games. What makes JavaScript games uniquely shareable?
AThey are smaller
BZero install: one file or one link and ANY device with a browser plays it instantly
CThey run faster than C++
๐๐๐ฎโจ๐
Workshop Complete!
Double jumps, wall slides, parallax and hand-written levels, six episodes and the browser is your game console. Build something original next! ๐จ๐