Wednesday, June 17, 2015

Bouncing Ball!

Today I will be changing this code (by Seb Lee-Delisle on Open Processing) This code prints a program that has a ball bouncing and its speed and height changes realistically like a ball.  

The first thing we are going to do is clean up the code and change the double slashes (//) to pound signs (#) Now we are going to change void setup(){} and void draw(){} to def setup (): and def draw (): and delete all the semi colons and curly brackets. Next we are going to add colons after all the if statements. Next we are going to delete the word float every time it appears. Next we are going to delete the else form the last if statement. Now we are going to change  void mousePressed(): to if (mousePressed): Now we are going to change the double lines in this statement; if ((x > width - w) || (x <= 0)): to the word "or" Now we are going to add 
  global x 
  global y
  global w
  global h
  global speedY
  global speedX
under def draw (): 
Your code should look like this:


Your code should should successful print a program that shows a bouncing ball.


1 comment: