help with flickering
Author |
Message |
lior.shay
|
Posted: Tue Sep 11, 2012 9:47 am Post subject: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Tue Sep 11, 2012 12:31 pm Post subject: RE:help with flickering |
|
|
You should try the search function. |
|
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Tue Sep 11, 2012 12:32 pm Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
QuantumPhysics
|
Posted: Wed Sep 12, 2012 7:36 am Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Wed Sep 12, 2012 7:46 am Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
QuantumPhysics
|
Posted: Thu Sep 13, 2012 12:28 am Post subject: RE:help with flickering |
|
|
Yes, listen to mirhagk. He understands much more than me, i am bad with turing. |
|
|
|
|
![](images/spacer.gif) |
|
|