Learn Create Your Own Split Screen

Next Page

However, it isn't falling smoothly.

Try making it move in smaller steps:

y_pos = y_pos + 1;

Try making it move more quickly.

setInterval(MyTimer, 40);
For most games and movies, you need at least 25 frames-per-second for animations to appear smooth. But setInterval specifies the number of milliseconds between ticks, so for 25 frames-per-second, we use 1/25th of a second, or 1000 divided by 25 (which is 40).


Make these two changes to the code below so the rectangle falls smoothly and more quickly.