This week, I was very fascinated with the concept of springs. After watching Professor Dan's tutorial on creating springy motion, I wanted to explore the concept of an 'anchor' and a 'bob' even further, and see if I could alter the relationship between those two particles.
In the tutorial, it seemed like the 'anchor' was a stationary particle, while the bob's velocity was able to be altered according to the location of the anchor itself. I thought it would be interesting to be able to imbue the anchor with some sort of motion as well, to create a push & pull effect. For my first draft, I simply changed the anchor into a 'bob' particle, and set the bob's location to the mouse location on the canvas. As I watched the bob drag the anchor around and off the screen, I couldn't help but think of sumo wrestling:
In sumo wrestling, one of the ways to win is to either toss or pull your opponent out of the ring. When I saw how my bob tossed the anchor out of the canvas, I decided to make a small game where two players are able to control their respective 'bobs' and attempt to push (or pull) the other player out of the canvas.

The 'bob' and 'anchor' objects are essentially the same particles with slight variations in visuals. In terms of physics qualities, they are the same. 

This is the Particle class of the 'bob' object, which contains vectors for acceleration, velocity, and position. It also contains a variable for mass. Force is applied, taking into account the object mass when altering the acceleration. The 'anchor' object possesses the same attributes.

An example of the display function for the Particle class (which is the same for the anchor object). If the ellipse were to leave the canvas, it would trigger the display of text, stating which player was the winner.

In order to achieve fluid motion of the objects, I utilized the smooth movement technique I picked up during the last few sessions working on my "Moths" and "Sharks" projects. 

Lastly, the inclusion of the spring object ensures the push & pull relationship between the 'bob' and 'anchor' objects. 

Link to Sketch (Player 1: Arrow Keys, Player 2: WASD keys):
Back to Top