Computer Science Canada

Lamp moving animation

Author:  bharath1000 [ Mon Dec 12, 2011 9:54 am ]
Post subject:  Lamp moving animation

im trying to make this lamp move... but it keeps on disapering
i want this lamp to move left to right without disapeering as it is haunted =D .



Turing:

%lamp
drawline (500, 240, 500, 600, 7)
drawfilloval (500, 200, 40, 40, yellow)
drawoval (500, 200, 40, 40, 7)
%moving lamp
for a : 1 .. 100 by 5
    drawline (500 + a, 240 + a, 500 + a, 600 + a, 7)
    drawfilloval (500 + a, 200 + a, 40, 40, yellow)
    drawoval (500 + a, 200 + a, 40, 40, 7)
    delay (50)
    drawline (500 + a, 240 + a, 500 + a, 600 + a, white)
    drawfilloval (500 + a, 200 + a, 40, 40, white)
    drawoval (500 + a, 200 + a, 40, 40, white)
    delay (50)
end for

Author:  mirhagk [ Mon Dec 12, 2011 10:39 am ]
Post subject:  RE:Lamp moving animation

I'm confused, your erasing it by drawing over it with white. The lamp should flash on and off with this code, you should look at how you have it structured:

draw lamp
wait 50 milliseconds
erase lamp
wait 50 milliseconds

How should that be changed?


: