Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

hey, I need help in computer processing. How do you get a shape to move according to the minute?

OpenStudy (konradzuse):

Explain?

OpenStudy (anonymous):

In computer processing, I have to type a code that makes a certain shape (ex. ellipse) move after every minute. For example, the following code makes a circle move from left to right. My problem is that I need help typing a code that makes the ball move across the window according to the minute. float cx; float cy; final float DIAM = 20; float xSpeed = 1.0; void setup() { size(350, 250); smooth(); cx = DIAM / 2.0; cy = height / 2.0; } void draw() { background(255); fill(0, 128, 128); ellipse(cx, cy, DIAM, DIAM); cx = cx + xSpeed; if (cx > width - DIAM / 2.0) // about to go off sketch at the right { xSpeed = -xSpeed; } if (cx < DIAM / 2.0) // about to go off sketch at the left { xSpeed = -xSpeed; } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!