1
votes

The code was:

open_window();
for(i=0;i<100000;i++){
    clear_the_window();
    draw_frame(i);
    wait_until_a_24th_of_a_second_is_over();
}

The book says the problem with this code is: Suppose the drawing takes nearly a full 1/24 second. Items drawn first are visible for the full 1/24 second and present a solid image on the screen; items drawn toward the end are instantly cleared as the program starts on the next frame.

I don't quite understand what does it mean by "first" and "toward the end"? If the three functions within the loop are called sequentially, what is the problem? Unless it is not a sequential program?

1

1 Answers

2
votes

Say this span of 10 stps covers 1/24th of a second:

  1. Clear window
  2. Item A begin drawing...
  3. A is drawn completely and visible for almost 1/24th second
  4. Item B begin drawing ...
  5. ...
  6. ... expensive drawing of B ...
  7. B finished drawing -> wont be shown too long
  8. Item C begin drawing...
  9. ...
  10. finished drawing C -> will last very short as next iteration is immanent

------- NEXT iteration -------

  1. Clear window
  2. and so on