Last modified on 1 November 2010, at 14:51

Turing/Graphics

This is how graphics should work:

View.Set ("offscreenonly")
loop
   Draw background picture
   Draw foreground stuff
   View.Update
end loop

In most cases, you must do it like this to avoid flicker.

Example: A moving circle:

View.Set ("offscreenonly")
for count : 1 .. 600
    drawfilloval (count, 200, 30, 30, red)
    View.Update
    delay (10)
    drawfilloval (count, 200, 30, 30, white)
end for

There are some commands in the example that you are probably not familiar with. A for loop is a counted loop it runs for a certain number of times. So the statement "For count : 1..600" means that the loop will run from 1 to 600, and each time it runs it will store that value in the variable "count". So the first time it will run count will have a value of 1, the second time it will be 2 and so on. "drawfilloval" does exactly what it says it draws an oval and fills it with the color specified. Delay also does what it says it pauses the program for a certain amount of time specified in the bracket, 1000 is equal to 1 sec so in the example it is 10, so program pauses for 0.01 s. The pause is needed so the program wait before it draws the white oval on top of the red one.


Arrays, flexible arrays