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>768) yinc=-5;

if (ypos<0) yinc=5;

if(xpos>1024) xinc=-3;

if(xpos<0) xinc=3;

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading Spencer | Coding at Georgia Stubbs.


%d bloggers like this: