top of page

Using Variables to Move Objects

Part 1. Move a circle from the middle of the screen to the right side of the screen.

See the sketch here.

I initially wanted to code the positions using height and width variables, but it didn't work :|

Part 2. Add 3 more circles: 1 moving left, 1 moving up, 1 moving down

See the sketch here

I added variable circleSpeed so that I could control the speed of all the circles in one variable. Otherwise, this was basically a copy and paste exercise with changes to the circle # and changing the x or y position value and changing the addition or subtraction function.

Part 3. Add 4 more circles, 1 moving toward each of the 4 corners of the canvas

See the sketch here

It's a good thing the canvas is square!

I added a second variable for speed to switch things up a bit. Otherwise, this is a pretty simple copy and paste exercise like before. Don't forget to add a value for either x or y for each corner circle

Part 4. Make one of your circles move 10x faster.

See the sketch here.


8 views0 comments

Recent Posts

See All
bottom of page