Instructables
Picture of How To Write Script To Make A Ball Move
g5.png
I am using The program from Khan Academy 
here is a link to it
http://www.khanacademy.org/cs/new
 
Remove these adsRemove these ads by Signing Up

Step 1: Step 1

Picture of Step 1
To make the background color  simply type          background(0,0,0)
to change the color click on one of the zeros and  you can click on what color you want

Step 2: Step 2

Picture of Step 2
To create the ball you need to type        ellipse(0,0,0,0)
the first  two zeros control where its placed on the page  aka the x and y axis
the second two zeros control how big the ball is
to control what color the ball is  put your cursor infrount of ellipse and hit enter  then go to the space above your ellipse and write fill(0,0,0)
it is the same way to change the color as the background

it should look like this
fill(0,0,0);
ellipse(0,0,0,0);

Tip: make sure you always have a semicolon ( ; )  after every command you type
     

Step 3: Step 3

Picture of Step 3
you need to make a variable for the first  zero of your ellipse
type  var x = 17

Step 4: Step 4

Picture of Step 4
How to make the movement of the ball
type                   var draw=       
2 brackets will come up copy and paste everything  in them except  the var  x = 17
 then at the bottom of the brackets (still inside the brackets) put
x = x+1
now your done you can see my creation on this link
http://www.khanacademy.org/cs/ball/1363117122

if you liked this post please follow me to see more


Ploopy1 year ago
could you make it to a .jar file?
then you could open it using java.
JesusGeek1 year ago
This is processingjs on the KhanAcademy coding environment. Check out some of my programs:
www.khanacademy.org/profile/TheFlipnzip (link may not work)