CS111 Reflection
A reflection on how I met all the requirements for CS111
Evidence Map: CS 111 Requirements Met
Object-Oriented Programming
| Requirement | Evidence | Code Reference |
|---|---|---|
| Writing Classes | Custom character classes extending base classes | Ghost.js - extends Enemy class |
| DeathBarrier.js - extends Barrier class | ||
| SpriteSheetCoin.js - extends Coin class | ||
| Methods & Parameters | Functions with 2+ parameters handling game logic | Ghost.js - parameters: player, distance calc |
| GameLevelOutside.js - parameters: player, skinKey | ||
| DeathBarrier.js - collision detection with params | ||
| Instantiation & Objects | Objects created and configured in level setup | GameLevelOutside.js - object instantiation |
| GameLevelMaze.js - configuration objects | ||
| Inheritance (2+ levels) | Multi-level class hierarchy demonstrated | Ghost extends Enemy (base game engine class) |
| DeathBarrier extends Barrier (base game engine class) | ||
| SpriteSheetCoin extends Coin (base game engine class) | ||
| Method Overriding | Override parent methods with custom implementations | Ghost.js - overrides parent update() |
| Ghost.js - custom collision handling | ||
| DeathBarrier.js - overrides barrier update | ||
| Constructor Chaining | Using super() to initialize parent class | Ghost.js - super(data, gameEnv) call |
| DeathBarrier.js - super(data, gameEnv) call | ||
| SpriteSheetCoin.js - super(data, gameEnv) call |
Control Structures
| Requirement | Evidence | Code Reference |
|---|---|---|
| Iteration (Loops) | For loops and forEach for game objects | Ghost.js - distance calculation loop |
| GameLevelOutside.js - Array.from and map | ||
| Conditionals (if/else) | Multiple conditional branches for game logic | Ghost.js - conditional OR logic |
| Ghost.js - if/else collision distance check | ||
| DeathBarrier.js - multi-level conditionals | ||
| Nested Conditions | Complex decision logic with multiple conditions | DeathBarrier.js - grace period + collision check |
| Ghost.js - nested conditions for direction |
Data Types
| Requirement | Evidence | Code Reference |
|---|---|---|
| Numbers | Position, velocity, scale factors | Ghost.js - velocity.x, velocity.y |
| GameLevelMaze.js - position/scale calculations | ||
| Strings | Character names, sprite paths, dialogue | GameLevelOutside.js - character names |
| GameLevelMaze.js - level identifiers | ||
| Booleans | State flags and conditions | Ghost.js - state flags |
| DeathBarrier.js - collision flags | ||
| Arrays | Object collections and animation frames | GameLevelOutside.js - object arrays |
| GameLevelMaze.js - maze walls | ||
| Objects (JSON) | Configuration objects and sprite data | GameLevelOutside.js - config objects |
| GameLevelMaze.js - maze config |
Operators
| Requirement | Evidence | Code Reference | ||
|---|---|---|---|---|
| Mathematical Operators | Calculations for physics and positioning | Ghost.js - Math.hypot(dx, dy) distance | ||
| Ghost.js - speed calculations | ||||
| String Operations | Path concatenation and text manipulation | GameLevelOutside.js - text composition | ||
| Boolean Operators | AND/OR logic for compound conditions | Ghost.js - && operator | ||
| DeathBarrier.js - && and | operators |
Input/Output
| Requirement | Evidence | Code Reference |
|---|---|---|
| Keyboard Input | Event listeners for WASD/arrow key controls | GameLevelOutside.js - W,A,S,D keys |
| GameLevelMaze.js - arrow keys | ||
| Canvas Rendering | Drawing sprites and game elements | SpriteSheetCoin.js - sprite rendering |
| Ghost.js - entity rendering | ||
| GameEnv Configuration | Canvas size and difficulty settings | GameLevelOutside.js - width, height, path |
| GameLevelMaze.js - environment setup | ||
| API Integration | AI NPC interaction with backend | GameLevelOutside.js - AiNpc interaction |
| GameLevelOutside.js - Q&A data structure | ||
| Asynchronous I/O | Async/await for image loading and transitions | SpriteSheetCoin.js - image onload |
| GameLevelOutside.js - async/await promises | ||
| JSON Parsing | Parse configuration objects and API responses | GameLevelOutside.js - JSON structure |
Documentation
| Requirement | Evidence | Code Reference |
|---|---|---|
| JSDoc Comments | Comprehensive function and class documentation | GameLevelOutside.js - class docs |
| SpriteSheetCoin.js - method docs | ||
| Code Comments | Strategic inline comments explaining logic | DeathBarrier.js - debug comments |
| Ghost.js - logic explanation |
Debugging
| Requirement | Evidence | Code Reference |
|---|---|---|
| Console Debugging | Strategic console.log for state tracking | DeathBarrier.js - collision logging |
| Ghost.js - state tracking | ||
| Error Handling | Try/catch blocks for robustness | GameLevelMaze.js - try/catch |
| GameLevelOutside.js - error handling |
Testing & Verification
| Requirement | Evidence | Code Reference |
|---|---|---|
| Gameplay Testing | Complete level with collision, NPC interaction, transitions | Castle Grounds Level and Maze Level |
| Integration Testing | Level transitions, NPC dialogue, AI responses work together | GameLevelOutside.js - integrated flow |
| API Error Handling | Error catching and graceful degradation | GameLevelOutside.js - API error handling |
Custom Classes Overview
1. Ghost.js (Hostile NPC - Extends Enemy)
- Documentation: Ghost Class Details
- Features:
- Inheritance from Enemy class
- AI pathfinding with followPlayer() method
- Collision detection and death handling
- Dynamic direction management
2. DeathBarrier.js (Collision Trigger - Extends Barrier)
- Documentation: DeathBarrier Class Details
- Features:
- Inheritance from Barrier class
- Grace period implementation (prevents instant death)
- Collision detection with logging
- Level state management
3. SpriteSheetCoin.js (Collectible - Extends Coin)
- Documentation: SpriteSheetCoin Class Details
- Features:
- Inheritance from Coin class
- Sprite sheet rendering with frame selection
- Async image loading
- Fallback rendering logic
Game Levels with Full Integration
Level 1: Castle Grounds (GameLevelOutside)
- Documentation: Castle Grounds Level
- NPC Interactions: Sir Morty (AI knowledge base), DarkKnight (level transition)
- Player Customization: 3 knight skins with localStorage persistence
- Scene Transition: Elaborate fade-in with starfield parallax and typed dialogue
Level 2: The Maze (GameLevelMaze)
- Documentation: The Maze Level
- Custom Enemies: Ghost class with follow behavior
- Collision System: 19 DeathBarrier instances defining maze walls
- Level Flow: NPC interaction leading to fortress transition