Week 3 – Functions, Arrays, and Object-Oriented Programming

For this project, I started with the really basic car code that was shared with us as an example. I liked how simple and clear it was, so I decided to build on that idea. I kept the general structure and movement the same, but instead of a car, I turned it into a spider. That meant changing the shapes, adding legs, and making it look a little more alive.

One thing I found pretty challenging was getting the legs to wiggle naturally. At first, they either didn’t move at all or moved in a really awkward way. It took me some trial and error, especially using functions like sin() and playing around with timing, to get it just right. In the end, I was able to make the spider’s legs move in a subtle way, which makes it feel like it has a bit of personality as it crawls around the canvas.
// make legs wigle
  legWiggle(index) {
    const phase = index * 10;
    return sin((frameCount + phase) * 0.05) * (this.legLength * 0.15);
  }
This piece of code makes the spider’s legs wiggle a bit, and it was honestly the hardest part for me. I had to keep experimenting with the numbers until the movement looked smooth and natural instead of random or awkward.

Leave a Reply