CMPT 166 Lecture Notes - Lecture 10: Ellipse

49 views8 pages

Document Summary

In this note we"ll see how to get an object to recognize the edges of the screen by using if-statements. Lets start with a program that makes a ball move slowly down the screen. // draw the ball nostroke(); fill(255, 0, 0); ellipse(x, y, 50, 50); x += 0; // add 0 to x y += 1; // add 1 to y. Now lets modify this so that the ball wraps-around to the top of the screen. The means after it hits the bottom, it jumps back to the top. To do this, we need to know when the ball has hit the bottom. Every time draw() runs, it now checks to see if y is bigger than 499, i. e. if the ball has hit, or passed, the bottom of the screen. If it has hit the bottom, then y is set to 0 so that on the next call todraw() the ball starts at the top.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions