Spencer | Coding
November 6, 2013 § Leave a comment
I am sad to inform you that Kyle Chandler didn’t get to make an appearance in this tutorial. (I know you’re upset.)
The beginning section of the code is finding the points to position and these are what we call ‘xpos‘ and ‘epos‘. (These are made up and just a way of remembering the points.) To represent the speed of the axes we’re using we use the titles “float yinc;” and “float xinc;”.
The “float xpos2;” and “float ypos2;” show us the variables that control the position of the still point. We then set random poistion points for the moving item. ”xpos=random(1024);” same for the ypos underneath set a fixed speed and “yinc=5;” and “zinc=3;.” was used in order to set a random position for the still point.
We added the x and y speed to the desired positions using the code underneath the drawing of the line. We then start using more complicated coding:
if (ypos<0) yinc=5;
The ‘if‘ code is relating back to the canvas size. Therefore, if we go out of the top screen it will send the point towards the bottom and if it goes to the bottom it will send the point to the top. This whole code made the points bounce from the edges.