Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Simple Motion [6/10]

This program draws a moving disc.
[Run the program]

The value of variable i specifies the distance from the left edge of the screen to the center of the blue disc.

In each iteration of the for loop, one animation frame is drawn to the screen.

Exercises:

1. Can you make the disc move faster, WITHOUT changing the statement sleepMs(30) ?

Hint 1

How much is the step of the for loop?

Solution 1

for #i=1..860 +=5

Solution 2

disc(i*5, 300, 100, /blue);

2. Change the pause time in the sleepMs statement to value 400 to view each animation frame separately.

Loading...