Computer Science Canada

animate cover

Author:  msimard8 [ Mon Nov 29, 2004 4:36 pm ]
Post subject:  animate cover

hello, how can i get this oval to move without covering up the background.


code:


drawfillbox (1, 1, 679, 300, red)
drawfillbox (1, 300, 679, 479, blue)

for c : 1 .. 400
    drawfilloval (1 + c, 300, 30, 30, green)
    delay (100)

    drawfilloval (1 + c, 300, 30, 30, red)%..........heres my problem

end for

[/code]

Author:  Cervantes [ Mon Nov 29, 2004 4:42 pm ]
Post subject: 

Just take your background and redraw it:
code:

for c : 1 .. 400
    drawfilloval (1 + c, 300, 30, 30, green)
    delay (100)

    drawfillbox (1, 1, 679, 300, red)
    drawfillbox (1, 300, 679, 479, blue)
end for

This works, but I think it's better structure if you keep all your drawing commands together, then put the delay after them, not having the drawing commands spread across the loop.

code:

for c : 1 .. 400
    drawfillbox (1, 1, 679, 300, red)
    drawfillbox (1, 300, 679, 479, blue)
    drawfilloval (1 + c, 300, 30, 30, green)
    delay (100)
end for

It's more understandable this way. You can tell easily that the background (the two drawbox lines) are behind the circle.
This is more important in larger programs. Wink


: