Getting Started — Editors & Workflow
Every week you copy real game files into your own folder on your PC, edit them in your own editor (VS Code or Sublime Text), and view them in the browser. There is no server, no PHP and no database for these labs — you just open the HTML files directly.
📁 Create your own folders
Make one folder on your PC for each lab week, named exactly like this:
Week1 Week2 Week3 Week4
Week5 Week6 … up to Week14
For example, put them inside a folder called WebGames on your Desktop or in your Documents.
Your work for each week stays in its own week folder.
diceGame_yourname.html), then edit that copy.
📋 Copy the example files
The class website is where you get the example games. For each file in the lab activity:
- Open the week's lab page on the class website.
- Choose the game in the Finished example dropdown and press Download file (or right-click the game link and choose Save link as…).
- Save it into your
WeekNfolder. - Repeat for every file named in the activity.
🌐 Open in a browser (no server)
- Open the class website by double-clicking its
index.html. - Double-click any file in your
WeekNfolder to open it in your default browser. - After editing, press F5 (or Ctrl+F5) to refresh and see the change.
file:///…). There is nothing to install or
start on a server.
🧊 3D weeks (7–14): Node.js, npm and Vite
From Week 7 every week is a small Node.js project. npm installs Three.js into the project, and the Vite dev server runs it in the browser and reloads the page every time you save. A 3D page opened by double-clicking the file stays blank — always open it through Vite.
Once: install Node.js
- Download the LTS version from nodejs.org and install it with the default options (npm comes with it).
- Open a new terminal and check:
node -vandnpm -vboth print a version number.
Every week: create the project
- Create a
WeekNfolder and open it in VS Code (File → Open Folder…). - Open the terminal (Ctrl+`) and run:
npm init -ynpm install three@0.170.0npm install --save-dev vite@5 - Or download the week’s
package.jsonfrom the lab page into the folder and runnpm install.
Every lab: run it
- In the terminal run
npx viteand leave it running. - Open
http://localhost:5173/plus your file name, e.g.http://localhost:5173/cubeStack.html. - Save in VS Code: the page reloads by itself. Stop Vite with Ctrl+C.
Handing in and publishing
- Zip your week folder without
node_modules(it is large).package.jsonis enough:npm installdownloads everything again. - For the final project,
npx vite buildmakes adistfolder that runs on any web server.
import * as THREE from "three" and add-ons such as
import { OrbitControls } from "three/addons/controls/OrbitControls.js" are found by Vite in
node_modules — there are no library files to copy. “Failed to resolve import”?
Run npm install in the folder that has package.json.
💻 VS Code setup
- Install Visual Studio Code from code.visualstudio.com.
- Recommended extensions: HTML CSS Support, Prettier, Path Intellisense.
- Weeks 1–6: optional Live Server extension for auto-refresh. Weeks 7–14 use Vite instead (see 3D weeks).
- Open your work: File → Open Folder… and choose your
WeekNfolder. - Click a game file in the Explorer to open it.
- Save with Ctrl+S, then refresh the browser (or use Live Server).
File → Open Folder… → Week2📝 Sublime Text setup
- Install Sublime Text from sublimetext.com.
- Install Package Control (Tools → Install Package Control), then add HTML5, Emmet and ColorPicker if you like.
- Open your work: Project → Add Folder to Project… and choose your
WeekNfolder. - Use the sidebar to click a game file.
- Save with Ctrl+S, then double-click the file (or refresh the browser tab) to test.
Project → Add Folder to Project…🔄 Weekly workflow
- Create (or open) your
WeekNfolder. - Copy the example files named in the lab activity into it.
- Open the week's lab page and read the Objectives and the Lab activity steps.
- Work through each file in order, saving and refreshing as you go.
- Tick the checkpoints and the Tasks for this file boxes on the lab page.
- Finish with the Exit quiz, then submit your copies.
🔄 Preview tips
- Double-click an HTML file to open it in your default browser.
- After editing, press F5 (or Ctrl+F5) to refresh.
- Right-click → Open with to choose a specific browser.
- Keep the lab page open in one tab and your game in another.
⌨ Useful shortcuts
| Action | VS Code | Sublime Text |
|---|---|---|
| Save file | Ctrl+S | Ctrl+S |
| Quick open file | Ctrl+P | Ctrl+P |
| Find in file | Ctrl+F | Ctrl+F |
| Comment / uncomment line | Ctrl+/ | Ctrl+/ |
| Format / re-indent document | Shift+Alt+F | Ctrl+Shift+P → Reindent |
| Refresh the browser | F5 | F5 |
📦 Submitting your work
- Keep all files for a week in that week's folder so relative paths keep working.
- Name every edited file with your student name:
slingshot_ali.html. - Before submitting, open each file in the browser and confirm it runs without errors (press F12 → Console to check).
- Zip your
WeekNfolder and upload it, or share it as instructed by your lecturer.
🔧 Troubleshooting
- Images or sounds missing? The file must sit in the same folder as its assets.
- Blank canvas? Open the browser console (F12) and read the first error — a typo in a variable name is the usual cause.
- Changes not showing? Save the file (Ctrl+S) and hard-refresh the browser (Ctrl+F5).
- Video/audio will not play? Some browsers block autoplay until you interact with the page.