Concept
This project is all about creating an interactive experience from the seek command where a magnifying glass chases after footprints on the canvas. When the magnifying glass “catches” a footprint, a new one pops up randomly, representing the excitement of exploration and discovery.
Highlight I’m proud of
I’m proud of how smoothly the magnifying glass interacts with the footprints. Watching it follow the moving footprints is super satisfying, especially with the slight speed difference
class MagnifyingGlass { constructor(x, y) { this.pos = createVector(x, y); this.vel = createVector(0, 0); this.acc = createVector(0, 0); this.maxSpeed = 1.5; // Slower speed for magnifying glass this.maxForce = 0.05; // Slower acceleration } seek(target) { let force = p5.Vector.sub(target, this.pos); force.setMag(this.maxSpeed); force.sub(this.vel); force.limit(this.maxForce); return force; } applyForce(force) { this.acc.add(force); } update() { this.vel.add(this.acc); this.vel.limit(this.maxSpeed); this.pos.add(this.vel); this.acc.set(0, 0); } followFootprints() { if (footprints.length > 0) { let target = footprints[footprintIndex].pos; let distance = p5.Vector.dist(this.pos, target); // If close to current footprint, remove it and generate a new one if (distance < 5) { footprints.splice(footprintIndex, 1); this.generateNewFootprint(); if (footprints.length > 0) { footprintIndex = footprintIndex % footprints.length; } } else { let force = this.seek(target); this.applyForce(force); } } }
Embedded sketch
Edit Sketch: https://editor.p5js.org/mariamalkhoori/sketches/LcZtAjZgp
Reflection and ideas for future work or improvements
- Footprint Movement: Right now, the footprints just wander randomly. I could make them move in more interesting patterns or even have them react to the magnifying glass’s position to make things more interactive.
- Sound Effects: Adding sound effects for when the magnifying glass catches a footprint could make the experience even more engaging.