How to Write Script to Make a Ball Move
by Nick-Smith-513 in Circuits > Computers
1503 Views, 8 Favorites, 0 Comments
How to Write Script to Make a Ball Move
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
to change the color click on one of the zeros and you can click on what color you want
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
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
you need to make a variable for the first zero of your ellipse
type var x = 17
type var x = 17
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
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