Introduction โ Why do we learn this way?
This course does not start with abstract theoretical concepts. Instead, we take real games that run on the internet โ Froggy Rush, Turtle Race and Castle Siege โ apart piece by piece, learning every concept exactly when we need it.
Every lesson solves a concrete problem in one of the games. We never learn something that doesn't have an immediately visible and understandable use.
You need no prior programming knowledge to complete this course. Only two tools are required: a text editor (e.g. VS Code, Notepad++) and a browser (Chrome, Firefox).
HTML (content structure) + CSS (appearance) + JavaScript (program logic). No Python, no C, no server โ everything runs in the browser with immediate, visible results.
Our goal is to build games that anyone can try on their phone โ the browser is the best platform for this. Python and C serve different purposes (data science, systems programming) โ those would be topics for a different course.
What will you be able to do by the end?
- Build a webpage from scratch
- Place text, images and links
- Set styles, colours and sizes
- Create a canvas element
- Make it look good on mobile (responsive)
- Work with variables and arrays
- Write conditions and loops
- Design and call functions
- Use objects and classes
- Handle events (click, key, touch)
- Draw shapes and images
- Write an animation loop (game loop)
- Implement collision detection
- Simulate movement and physics
- Build a save system
- Play and manage sounds
- Program AI opponents
- Deploy to Netlify
- Add mobile touch controls
Required tools
| Tool | Purpose | Where to get it |
|---|---|---|
| VS Code | Writing code, syntax highlighting | code.visualstudio.com (free) |
| Chrome / Firefox | Running the game, debugging (F12) | Already installed |
| Notepad++ | Alternative text editor | notepad-plus-plus.org (free) |
| Netlify | Publishing your game online (Phase 5) | netlify.com (free plan) |
Open a new file, save it as index.html, type: <h1>Hello!</h1> โ then double-click to open it in your browser. That is programming.
Course structure โ 50 lessons, 5 phases
HTML & CSS Basics โ Lessons 1โ10
We build the skeleton and appearance of a webpage. We learn document structure through Castle Siege's HTML layout.
JavaScript Basics โ Lessons 11โ20
The logic of programming. From variables to objects, illustrated through Froggy Rush's level generator code.
Canvas API & Animation โ Lessons 21โ30
Drawing, movement, collision โ the fundamentals of game graphics. Learned through drawing the turtle and the frog.
Dissecting Full Games โ Lessons 31โ45
We understand every line of three complete games: game state, physics, AI opponent, level generation.
Advanced Features & Publishing โ Lessons 46โ50
localStorage, sound handling, mobile D-pad, Netlify deploy. The game goes live on the internet.
Phase 1 โ HTML & CSS Basics
In the first phase we learn how a webpage is structured โ and along the way, what the Castle Siege game's HTML frame looks like from the inside.
<!-- Every webpage starts like this --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Castle Siege</title> <style> /* CSS goes here */ </style> </head> <body> <canvas id="c"></canvas> <!-- the game canvas --> <script> // JavaScript goes here </script> </body> </html>
HTML document structure
DOCTYPE, html, head, body โ what every tag means and why it's needed. We look at Castle Siege's frame.
HTMLText, headings, paragraphs
h1โh6, p, strong, em, br โ formatting text content. We analyse the game's score display.
HTMLLinks, images, lists
a, img, ul, ol, li โ navigation and content. The HTML of the site's game list.
HTMLdiv, span, id, class
The "boxes" of HTML โ how to group elements together. Building Castle Siege's HUD panels.
HTMLButtons and input elements
button, input, select โ interactive UI elements. The speed-change buttons and save field.
HTMLCSS โ Colour, font, size
color, background, font-family, font-size โ the first styles. Understanding the game interface's dark theme.
CSSCSS โ Box model
margin, padding, border, width, height โ why things aren't where you expected. Sizing the panel elements.
CSSCSS โ Flexbox layout
display:flex, gap, align-items โ the modern web layout system. Arranging the HUD buttons in a row.
CSSCSS โ Responsive design
@media, max-width, viewport โ how it looks on mobile. Adapting games for mobile screens.
CSS๐ Project: Game List Page
We build our own homepage where three games are listed as links โ like a real game portal.
ProjectPhase 2 โ JavaScript Basics
JavaScript is what brings a webpage to life. In this phase we learn from Froggy Rush and Galactic Conquest's code โ we always see exactly what each concept is good for in the game.
// Variables โ store data let lives = 3; // number let playerName = "Alex"; // string let isJumping = false; // boolean // Object โ related data grouped together const player = { x: 170, // horizontal position y: 406, // vertical position lives: 3, // number of lives energy: 100 // energy level }; // Array โ multiple items in a list const eggs = [ { x: 120, y: -200 }, { x: 260, y: -450 }, { x: 180, y: -700 } ];
Variables: let, const, var
What's the difference? When to use which? We use them to store the player's lives and score.
JavaScriptConditions: if, else, switch
The program makes decisions โ if energy runs out, a life is lost. Castle Siege's collision logic.
JavaScriptLoops: for, while, forEach
We need to repeat โ every enemy, every egg must be checked. Array iteration in the game.
JavaScriptFunctions โ reusable code
function, parameters, return value. Inside the drawTurtle() function โ draws a different turtle each call.
JavaScriptArrays and array methods
push, pop, filter, map, find โ enemies, eggs, towers all live in arrays.
JavaScriptObjects and properties
The game state is one big object. How do we design it? Why is it better than many separate variables?
JavaScriptEvent handling โ keyboard
addEventListener, keydown, keyup โ how the program detects key presses. The WASD control code.
JavaScriptEvent handling โ mouse and touch
click, touchstart, touchend โ mobile and desktop mouse handling. D-pad buttons and canvas clicks.
JavaScriptMath and randomness
Math.random(), Math.floor(), Math.sin() โ how we place eggs and rocks randomly.
JavaScript๐ Project: Mini quiz game
Using pure JavaScript (no canvas) we build a simple question-and-answer game.
ProjectPhase 3 โ Canvas API & Animation
The Canvas is the "drawing board" we draw the game onto. In this phase we learn how to draw shapes, characters โ and how to animate them.
// Getting the canvas element and drawing context const canvas = document.getElementById('gc'); const ctx = canvas.getContext('2d'); // The game loop โ runs 60 times per second function loop() { update(); // 1. updates the game state draw(); // 2. draws the current frame requestAnimationFrame(loop); // 3. calls itself again } // Drawing on the canvas function draw() { ctx.clearRect(0, 0, W, H); // clear ctx.fillStyle = '#4aaa22'; // set colour ctx.fillRect(100, 200, 50, 30); // draw rectangle }
Canvas basics โ the first line
getContext, fillRect, strokeRect, clearRect โ the first steps. We draw a road and a castle.
CanvasCircles, arcs, curves
arc(), beginPath(), closePath() โ we draw the turtle's body and head with these.
CanvasColours, transparency, gradients
rgba(), createLinearGradient(), createRadialGradient() โ the secret to visual depth.
CanvasThe game loop โ requestAnimationFrame
Why 60fps? How do we measure time? The concept of movement speed and DT (deltatime).
AnimationCoordinate system & transformations
translate(), rotate(), scale(), save(), restore() โ how to draw the turtle around its own axis.
CanvasDrawing text
fillText(), font, textAlign โ displaying score, names and feedback messages on the canvas.
CanvasCollision detection โ circle and rectangle
Math.hypot() distance calculation and rectangle overlap. The egg-collecting and rock-collision code.
PhysicsScroll and camera follow
How does the level scroll? World-space vs screen-space โ Turtle Race's coordinate system.
AnimationSprite animation โ walking, jumping
Math.sin() based cyclic motion โ how the turtle and frog walk without needing image files.
Animation๐ Project: Moving character
We draw our own character on the canvas, control it with the keyboard, and animate its movement.
ProjectPhase 4 โ Dissecting the Three Games
In this phase we take apart three complete games and understand them piece by piece. Each lesson examines one specific mechanism from the inside.
Procedural level generation
How do we place eggs, rocks and seagulls randomly but fairly? The evenSpread() function.
Froggy RushSurfaces and speed โ strategy pattern
The SURFACES object: how to store all surface properties in one place and read them dynamically.
Froggy RushJump physics โ Math.sin() parabola
How we calculate the frog's arc using sin(). The relationship between jumpT timer and jumpH height.
Froggy RushMulti-state game โ State Machine
play, dead, levelup, gameover โ the concept of the state machine. How does the game switch states?
Froggy RushDifficulty levels โ DIFF_CFG object
How do we change the entire game's behaviour with just one DIFF variable?
Froggy RushAI opponent โ targeting and navigation
How does the turtle AI decide: which egg is closest? How does it avoid seagulls? Weighted scoring.
Turtle RaceResource management โ Energy system
Energy drain per surface, recharging by collecting โ the mechanics of decision-making and trade-offs.
Turtle RaceCamera and world-space coordinates
Why are objects' y coordinates sometimes positive, sometimes negative? Screen-space vs world-space.
Turtle RaceDrawing characters in layers
Shadow โ legs โ body โ head โ eyes โ mouth โ the correct drawing order and using save/restore.
Turtle RaceTower Defense architecture
How is all of Castle Siege structured? Heroes, towers, enemies, projectiles โ all data in the G object.
Castle SiegeDynamic level generation โ genLevel()
50 different levels from one function. How do we scale difficulty with mathematics?
Castle SiegeBullet prediction โ lead prediction
The tower shoots not where the enemy IS, but where it WILL BE. Calculating speed and travel time.
Castle Siege๐ Project: Your own mini game
The student designs and builds their own simple game using what they've learned. Independent development.
Own ProjectPhase 5 โ Advanced Features & Publishing
localStorage โ saving in the browser
How does Castle Siege save level progress? JSON.stringify, JSON.parse, localStorage.setItem.
DataTop 10 leaderboard implementation
Sorting arrays, slice() โ how to maintain a list of best scores with names and points.
DataWeb Audio API โ music and sound effects
new Audio(), play(), base64 embedding โ why this approach and why Android can't load a separate file.
AudioMobile D-pad and touch handling
touchstart, touchend, pointer events โ how we built Froggy Rush and Castle Siege's mobile controls.
Mobile๐ Deploy โ Netlify upload
How does the game get onto the internet? Netlify account, drag-and-drop deploy, custom URL. Course wrap-up.
DeployAfter completing the course you'll be able to independently design and build simple browser games using HTML and JavaScript, and publish them online โ using nothing but a text editor and a browser.
Summary table
| Phase | Topic | Lessons | Est. time | Example game |
|---|---|---|---|---|
| 1. HTML & CSS | Webpage structure, styles, responsive design | 1โ10 | ~5 weeks | Castle Siege (HUD) |
| 2. JavaScript | Variables, conditions, loops, functions, arrays, objects | 11โ20 | ~6 weeks | Froggy Rush (logic) |
| 3. Canvas | Drawing, animation, collision, physics, camera | 21โ30 | ~6 weeks | Turtle Race (graphics) |
| 4. Games | Full game dissection, AI, state machine, level generation | 31โ45 | ~8 weeks | All three games |
| 5. Advanced | Saving, sounds, mobile UI, deploy | 46โ50 | ~3 weeks | Full implementation |
| Total | 50 lessons | ~6 months | 3 games live online | |
This document is the introductory part of Lesson 1. The individual lesson files contain detailed explanations, code examples and exercises โ always connected to specific lines of the games above.