Computer Science Canada

Movement Is "Glitchy"

Author:  Rasta Fella [ Sun Jan 15, 2006 11:18 am ]
Post subject:  Movement Is "Glitchy"

The source code below is part of the program I am making. Seems to me when I run the program the 'dot' seems to flash. Its a problem, because the commands states to redraw the dot every some odd milliseconds. Is there a way that the flashy stuff can be fixed...because I don't want a problem in the future to occur. Or is it just my computer?? I already looked through alot of the programs....and I think the command View.Update can help???

Code Below:

code:
    var x, y : int                                               
    x := 20                                                                                   
    y := 60                                                                                       
    var chars : array char of boolean                                                         

   
drawfillbox(0,0,560,350,black)   
   
loop
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        if y <= 348 then
            y := y + 1
        end if
    end if
    if chars (KEY_RIGHT_ARROW) then
        if x <= 559 then
            x := x + 1
        end if
    end if
    if chars (KEY_LEFT_ARROW) then
        if x >= 1 then
            x := x - 1
        end if
    end if
    if chars (KEY_DOWN_ARROW) then
        if y >= 45 then
            y := y - 1
        end if
    end if

    drawfilloval (x, y, 1, 1, white)
    delay (5)
    drawfilloval (x, y, 1, 1, black)
end loop

Author:  Cervantes [ Sun Jan 15, 2006 11:24 am ]
Post subject: 

View.Update will indeed help.

Stick this at the top of your program:
code:

View.Set ("offscreenonly")


Then, after you've drawn your dot, do a View.Update.

Author:  Rasta Fella [ Sun Jan 15, 2006 5:16 pm ]
Post subject: 

Thanks Crevantes, It works now...

P.S. I like your new avatar, better then the pirate I think...


: