NOC WEEK2
PROCESS
This week we’re refreshing our memories on sin and cos waves. I thought of the idea of having a little person escaping the waves as it passes by, so I could combine gravity which we learned last week.
I first created a sin wave using the formula to get the y values at any point in the sin wave, and used five different sin waves to create one single line. I then adjusted the canvas opacity to 10 so I could get some motion blur from the waves.
To create an ocean effect, I used another array to store all the waves parameters.
I referenced the force example code from the Nature of Code, but instead of the wind force, I used a upward force to influence the freefalling object. So the player can save Ege from falling by clicking on the mouse.
To check if Ege hits the waves on the axis, I used the y value to check if Ege’s body is intersecting with it. Once they intersect, Ege’s body turns 90 degrees.
REFERENCES
Additive Waves - The Nature of CodeCreating a Force - The Nature of Code