Sunday 1 May 2011

mouseX and mouseY + speed increaces

Speed increases the closer the cursor gets to the center of the screen.

By adding a variable called "speed", the value "a" is able to be given a new attribute.
"a" is used in the equation for the integer "y" or "int y", ("y" controls the height and length of each wave) to control the speed at which the wave sequence is.
By adding "a -= speed" we make "speed" the same as "a"; the "-" is used to make the waves come from the outside and sink into the middle.

the "speed" equation is as follows:

speed = (width/2-dist(mouseX,mouseY, width/2,height/2)) / (width/2);

It shows that the starting point of the wave is going to be wherever the mouse is and that the speed is going to change depending on how far the cursor is from the center of the window.


We use " / (width/2);" at the end because we need to devide it by two to slow it down even
more.

"width/2-" at the begining to invert where the speed up is occuring.

No comments:

Post a Comment