Documentation Showcase
Documentation
Table of Contents
Documentation is about explaining your code, process, and learning journey. It helps others understand your work and supports collaboration.
Subrequirements
Code Comments
- Pong Game: Inline comments throughout code (View Pong Game)
- Homeworks: Homework Summation
// From hacks/pong.md — well-commented Config block explaining every setting
// -----------------------------
// Config: Tweak these values
// -----------------------------
const Config = {
canvas: { width: 800, height: 500 },
paddle: { width: 10, height: 100, speed: 10.5 },
ball: { radius: 10, baseSpeedX: 5, maxSpeed: 15 },
// TODO[Students]: Remap keys if desired
keys: { p1Up: "w", p1Down: "s", p2Up: "ArrowUp", p2Down: "ArrowDown" },
visuals: { bg: "#000", fg: "#fff", text: "#fff", gameOver: "red", win: "yellow" }
};
/**
* Paddle — a moveable rectangle controlled by a player or AI.
* @param {number} x - Horizontal position (pixels from left)
* @param {number} y - Vertical position (pixels from top)
* @param {number} boundsHeight - Canvas height, used to clamp movement
*/
class Paddle {
constructor(x, y, width, height, speed, boundsHeight) {
this.position = new Vector2(x, y);
this.width = width;
this.height = height;
this.speed = speed;
this.boundsHeight = boundsHeight;
}
}
Code Runner Challenge
Hit Run to see JSDoc-style comments in action. The code logs each method's documentation description alongside its result — the same commenting density (>10%) required for the CS111 code review.
Quick Quiz: Code Comments
- Why are comments important in code?
- a) They make code run faster
- b) They help explain what the code does
- c) They are required for all variables
- What is a JSDoc comment?
- How can comments help you when you revisit your code later?
Show Answers
1. b) They help explain what the code does 2. A special comment format that documents functions, classes, and parameters for tools and IDEs. 3. They remind you (or others) what the code is doing and why, making it easier to update or debug.Mini-Lesson Documentation
- Night at the Museum Blog: Visual narrative with embedded game demo (Night at the Museum)
- Pong Hack Post: Step-by-step mini-lesson with embedded playable Pong (View Pong Game)
- Accomplishments Blog: Key Accomplishments
// From hacks/pong.md — Student Challenges section documents learning objectives inline
// -----------------------------------------
// Student Challenges (inline TODO checklist)
// -----------------------------------------
// 1) Make it YOUR game: change colors in Config.visuals, dimensions/speeds in Config.
// 2) Add AI: implement simple tracking for right paddle in handleInput. DONE
// 3) Rally speed-up: every time the ball hits a paddle, slightly increase |velocity.x|.
// 4) Center line + score SFX: draw a dashed midline; play an audio on score.
// 5) Power-ups: spawn a rectangle; when ball hits it, apply effect (bigger paddle?).
// 6) Pause/Resume: map a key to toggle pause state and skip updates when paused.
// 7) Win screen polish: show a replay countdown, then auto-restart.
// From Nightatthemuseum.md — front matter documents the post's learning narrative
// ---
// layout: post
// title: Night at the Museum
// description: Reflection on presenting our game at the school showcase
// ---
Code Runner Challenge
Hit Run to see a mini-lesson format in code — a self-documenting challenge list printed alongside result output. This is the same pattern used in hacks/pong.md to teach students what to try next.
Code Highlights
- Pong Game: Highlighted collision, power-up, and class code with inline explanations (View Pong Game)
- Local Storage Demo: Highlighted leaderboard API and localStorage usage (Local Storage Demo)
- Accomplishments Blog: Key Accomplishments — code snippets with commentary
// From _projects/local-storage/levels/localStorageDemo.js
// KEY HIGHLIGHT: localStorage persists coin count across page refreshes
// ─────────────────────────────────────────────────────────────────────
const coinsCollected = parseInt(localStorage.getItem('coinsCollected') || '0');
// ^ reads stored value, defaults to '0' if absent
localStorage.setItem('coinsCollected', coinsCollected + 1);
// ^ key must match exactly or you create a second entry
// KEY HIGHLIGHT: OOP — reaction() is a method override on the Coin object
// ─────────────────────────────────────────────────────────────────────────
reaction: function () {
if (!this.collected) {
this.collected = true; // ← boolean flag prevents double-counting
const coinsCollected = parseInt(localStorage.getItem('coinsCollected') || '0');
localStorage.setItem('coinsCollected', coinsCollected + 1);
// Dispatch event so leaderboard can listen without tight coupling
document.dispatchEvent(new CustomEvent('coinCollected', { detail: { total: coinsCollected + 1 } }));
}
}
Code Runner Challenge
Hit Run to see annotated code highlights — the same key snippets that would appear in a portfolio documentation page, with comments explaining WHY each line matters, not just WHAT it does.
Project Documentation
- Accomplishments Blog: Key Accomplishments
- N@TM Blog: Night at the Museum
// From hacks/pong.md — Student Challenges section documents learning objectives inline
// -----------------------------------------
// Student Challenges (inline TODO checklist)
// -----------------------------------------
// 1) Make it YOUR game: change colors in Config.visuals, dimensions/speeds in Config.
// 2) Add AI: implement simple tracking for right paddle in handleInput. DONE
// From _projects/local-storage/levels/localStorageDemo.js — inline comment documents a bug fix
const image_src_desert = path + "/images/gamify/forest.png";
const image_data_desert = {
name: 'forest',
src: image_src_desert, // ← was image_src_forest (bug fix documented in comment)
pixels: { height: 580, width: 1038 }
};
Gamerunner — Documentation in Pong
Challenge
Documented Pong — every class and method has JSDoc comments