IAT265 Liner Motion Animation Example.docx

2 Pages
Unlock Document

Simon Fraser University
Interactive Arts & Tech
IAT 265
Matt Lockyer

Linear Motion Animation float xPos, yPos, dx, dy, rotation, objectSize; void setup() { size(500, 500); smooth(); objectSize = 20; // inialize the object size; in this case, the diameter xPos = objectSize/2; // move the object on screen to start yPos = objectSize/2; dx = 1; // x velocity, or the small amount added to xPos each frame dy = 3; // y velocity, or the small amount added to yPos each frame /** Change dx and dy to change the direction the object moves. Negative values move the object left and up. Postive values move the object down and right. **/ // calculate the angle of the object's heading rotation = atan(dy / dx); } void draw() { background(255); // clear the background by setting it to white each frame drawObject(xPos, yPos, rotation, objectSize); // draw the object on screen // UPDATE positions for next frame // increment the xPos by the amount dx xPos += dx; // increment the yPos by the amount dy yPos += dy; // logic to make the object loop on screen if (xPos > width + objectSize / 2
More Less

Related notes for IAT 265

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.