Jason's notes

Week4 Oscillation

In terms of something that oscillate and move, the first thing came up to my mind is rowing. My idea was to make a boat that only proceeds while paddling. So the movement would be a loop between acceleration and slowing down.

Here is the final result, you may also access it by p5 editor.

Click to move the flag (target)

Process

To be honest, I’m not familiar with rowing at all, so I did some search. And it was really interesting to find out that players are actually facing toward the stern which is the opposite of what I thought at first. Here are some references:

As the video shows, boat acceleration could be pretty complicated in real life. So I just simplify the paddle movement to a circle, and only applies acceleration to the boat when they are underwater which I was assuming when at the hight range from -1 to -0.2. Therefore, the magnitude of acceleration is calculated in this way:

const magnitude = max(
  map(cos(this.phase), -1, -0.2, 0.02, 0),
  0
);

I also added some effect when a part of the paddle is underwater which is calculated in a similar way.

The attraction part is arranged from Gravitational Attraction by the Coding Train. I did some modification including changing the attractor to a flag and making the players row faster when they are far from the target.

Plan

I am planning to make it a multiplayer game in the following weeks, and add features like:

  • Individual paddle control
  • Collision detection
  • Water flow effect (particles)