
-----------------------------------
santabruzer
Sat Nov 22, 2003 8:16 pm

Need help with Movement
-----------------------------------
Here.. Let's say i have a program that start out with something like this:
import GUI in "%oot/lib/GUI" 
var x : array 1 .. 4 of int := init (155, 165, 160, 160)
var y : array 1 .. 4 of int := init (0, 0, 0, 5)
var chars : array char of boolean
var line :int
setscreen ("graphics:320;320")
loop
Input.KeyDown (chars)
line := GUI.CreateLine (x(1), y(1), x(2), y(2), 0)
line := GUI.CreateLine (x(3), y(3), x(4), y(4), 0)
        if chars (KEY_RIGHT_ARROW) then
            for i : 1..4
                x(i) := x(i) + 1
                delay(3)
                cls
                drawline (x(1), y(1), x(2), y(2), 1)
                drawline (x(3), y(3), x(4), y(4), 1)
            end for
        end if
        if chars (KEY_LEFT_ARROW) then
            for i : 1..4
                x(i) := x(i) - 1
                delay(3)
                cls 
                drawline (x(1), y(1), x(2), y(2), 1)
                drawline (x(3), y(3), x(4), y(4), 1)
            end for
        end if
end loop


I think the GUI is pointless here.. but anywho.. what can i do instead of "cls"?

-----------------------------------
Tony
Sat Nov 22, 2003 9:11 pm


-----------------------------------
what the :shock:

GUI is used to draw lines... which is pointless :?

anyways, instead of cls, you can just redraw the screen. which would be

Draw.FillBox(0,0,maxx,maxy,white)


-----------------------------------
Blade
Sat Nov 22, 2003 10:16 pm


-----------------------------------
well, it seems like you're trying to get rid of flicker... and you obviously are using turing 4.x so you can use

setscreen("offscreenonly")
and
View.Update

this will get rid of your flicker.
the offscreenonly sets the the program so that you update the screen with the command View.Update. so whenever you call View.Update the screen will refreash all at once, instead of refreashing every time you put something out.

-----------------------------------
santabruzer
Sat Nov 22, 2003 11:08 pm


-----------------------------------
Thanx.. that explanation clears it all...  :D
