# Game Project Commentary

## Extensions

The extension I implemented is the **platforms** system, using the factory pattern. I wrote a `makePlatform()` factory function that creates platform objects with position, dimensions, speed, and boundary properties. I decided to make the platforms move horizontally rather than keep them static — each one oscillates between two bounds and reverses direction when it hits a limit. To make this work, I had to coordinate two things: the platform updating its own position in `drawPlatform()`, and the character being carried along by the platform's velocity in `checkPlatform()`. I placed five platforms across the level, some bridging canyons and others leading up to floating collectables, so they feel like a real part of the level rather than an afterthought.

I also applied two advanced techniques. I split the code across **multiple files**, giving each game element its own script (`character.js`, `platform.js`, `collectable.js`, etc.) and pulling shared constants and colours into a `variables/` directory. Throughout, I used **ES6 syntax** consistently — `const`/`let`, `for...of` loops, and the spread operator for animation state updates.

## Difficulties

The hardest part for me was getting the platform collision detection right. I found it tricky to make the character land cleanly on a moving platform without clipping through or bouncing off. It took a fair bit of tuning on the surface threshold and making sure the position update was in sync with the platform each frame.

## Skills Learnt and Practised

Working on this project helped me get much more comfortable with breaking a program into small, focused functions and files. I practised the factory pattern properly for the first time and got a much better feel for coordinate transformations — using `push()`/`pop()` with `translate()` and `rotate()` to build up layered animations. Drawing the character's five animation states taught me to think carefully about how to map visual states to conditional logic. I also came away with a better appreciation for consistent naming and inline comments; with the code spread across multiple files, those small habits made a real difference to how easy it was to navigate.
