
-----------------------------------
lior.shay
Tue Sep 11, 2012 9:47 am

help with flickering
-----------------------------------
hi, this is my code, and i cant seem to stop the flickering, can someone please help me?

View.Set("graphics:600;700")
View.Set("nocursor")
View.Set("position:center;truemiddle")
View.Set("nobuttonbar")



var x,y:int 
x:=350
y:=350
var keypress : array char of boolean

loop
Input.KeyDown (keypress)

if keypress (KEY_RIGHT_ARROW) then
x:=x+5
end if

if keypress (KEY_LEFT_ARROW) then
x:=x-5
end if

if keypress (KEY_UP_ARROW) then
y:=y+5
end if

if keypress (KEY_DOWN_ARROW) then
y:=y-5
end if


Draw.FillStar(x,y,500,700,yellow)
delay(20)

cls

end loop

-----------------------------------
Insectoid
Tue Sep 11, 2012 12:31 pm

RE:help with flickering
-----------------------------------
You should try the [url=http://compsci.ca/v3/search.php?mode=results]search function.

-----------------------------------
mirhagk
Tue Sep 11, 2012 12:32 pm

RE:help with flickering
-----------------------------------
View.Set("offscreenonly");

then after you draw everything (right before the delay) do View.Update.


What this does is create a 2nd buffer to draw everything to. Then when you call View.Update it switches the window with this 2nd buffer. That makes everything update all at once, and will remove most of your flickering.

-----------------------------------
QuantumPhysics
Wed Sep 12, 2012 7:36 am

RE:help with flickering
-----------------------------------
Make a View.Update(); after the delay because it should control the buffering so it doesnt interfere before a short pause in the program? If that made sense.

-----------------------------------
mirhagk
Wed Sep 12, 2012 7:46 am

RE:help with flickering
-----------------------------------
No do View.Update before the delay, otherwise the picture you see will always be 20ms (or however long your delay is) old. Also you should use Time.DelaySinceLast, which delays up to however many milliseconds you do, it takes into account how many milliseconds the current loop took to run.

-----------------------------------
QuantumPhysics
Thu Sep 13, 2012 12:28 am

RE:help with flickering
-----------------------------------
Yes, listen to mirhagk. He understands much more than me, i am bad with turing.
