Interactive Web Games Lab

Learn HTML5 game development by reading, running, and rewriting real games. Every lab gives you the objectives, a guided file-by-file activity, a live preview of each game, and checkpoints you tick off as you go.

Canvas 2D JavaScript Animation Physics Audio & Video Game Logic

📚 Introduction: what this lab is

This lab teaches HTML5 and JavaScript by building complete, playable games — the same teaching approach used in The Essential Guide to HTML5: Using Games to Learn HTML5 and JavaScript (3rd edition) by Jeanine Meyer. Rather than learning the language in isolation, you start with a small working game and grow it step by step, one idea at a time.

Each of the six weekly labs is adapted from one of the book's games and follows the same objectives → guided build → complete-the-code flow:

Everything is written in plain HTML5, the Canvas 2D API and JavaScript — no frameworks and no libraries — so what you write is standard web technology you can reuse anywhere.

The games you build include the Craps dice game, the bouncing ball, the cannonball and slingshot, the memory (matching) game, and an ordering quiz with audio and video rewards. Examples and game ideas are adapted from The Essential Guide to HTML5 (3rd ed.) by Jeanine Meyer.

Week 1

HTML5 Foundations

Document structure, elements, attributes, images, links, semantic tags and a first taste of CSS.

structureCSS basicsDOM
Week 2

Canvas & the Dice Game

Draw with <canvas>, generate random numbers, handle clicks and build the Craps dice game.

canvasrandomevents
Week 3

Animation, Inputs & Media

Animate with timers, bounce a ball off walls, wire up form inputs and mix in images, gradients and video.

setIntervalcollisionmedia
Week 4

Objects & Physics

Build reusable game objects, follow mouse input and launch a projectile with gravity in the slingshot game.

objectsmousegravity
Week 5

Memory Game

Arrays, images, shuffling, click hit-testing and match logic — plus drawing polygons on the canvas.

arraysshufflematching
Week 6

Audio, Video & Rewards

Control media from JavaScript and build an ordering quiz that rewards correct answers with sound and video.

audiovideoquiz logic

🧊 Part 2: 3D web games with Three.js (Weeks 7–14)

From Week 7 the games move into 3D. Each week uses Three.js (r170), the most widely used 3D library for the web, and ends with a complete, playable 3D game. The JavaScript skills from Weeks 1–6 (events, game loops, collision and scoring) carry straight over.

Each 3D week is a small Node.js project: npm install three installs Three.js and npx vite runs it (Week 7 shows how to install Node.js). See the Setup guide.

Week 7

Your First 3D Game

Scene, camera, renderer, meshes and the animation loop — build Cube Stack, a stacking game.

scenemeshloop
Week 8

Shapes, Lights & Shadows

Materials, spot and point lights, shadows and orbit controls — search a dark room in Torch Hunt.

lightsshadowsorbit
Week 9

Movement & Follow Camera

Keyboard state, steering with sin and cos, groups and a chase camera — drive and park in Park It!

keyboardvectorscamera
Week 10

3D Collision Detection

Bounding boxes, walls, pick-ups and hazards — grab every coin and dodge the spikes in Coin Collector.

Box3pick-upslives
Week 11

Mouse Picking

Click on 3D objects with a Raycaster, hover effects and timed spawns — play Whack-a-Mole 3D.

Raycasterpointertimers
Week 12

Gravity & Projectiles

Velocity, gravity, aiming and impacts — Week 4’s cannonball returns in 3D in Cannon Tower.

physicsaimingvectors
Week 13

Textures, Sound & HUD

Canvas textures, Web Audio sound effects and an on-screen HUD — a polished shooting gallery, Target Range.

texturesaudioHUD
Week 14

Final Project: Endless Runner

Game states, spawning, object pooling, fog and difficulty — put it all together in Lane Runner.

game statespoolingproject

⚙ How to use a lab

  1. Create your own folder for the week (for example Week1) on your PC and copy the example files you need from this site into it.
  2. Open that week folder in VS Code or Sublime Text.
  3. Follow the Lecture activity slides with your lecturer (the Lecture slides button on each week).
  4. Read the Objectives, then work through the Lab activity steps file by file. Tick each checkpoint as you finish.
  5. The Finished example output box already shows the completed game for the week — use the dropdown to preview another example.
  6. Edit the game files in your editor, save, then double-click the file (or refresh the tab) to see the change.
  7. Use the Tasks for this file panel and its Hint button when you are stuck (ask your lecturer before Show solution).
  8. Finish with the Exit quiz — it is your ticket out of the lab.
  9. Save your graded copy as filename_yourname.html in the same week folder.

No server needed: just open index.html in your browser. Progress and quiz scores are saved in this browser only. Lecturers can add ?answers=1 to a lab URL to reveal all hints and solutions.

New to the tools? Read the Setup guide for VS Code and Sublime Text instructions.