Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help with flickering
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lior.shay




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Sep 11, 2012 12:31 pm   Post subject: RE:help with flickering

You should try the search function.
mirhagk




PostPosted: 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.
QuantumPhysics




PostPosted: 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.
mirhagk




PostPosted: 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.
QuantumPhysics




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: