Computer Science Canada How can i get my code not to flacker?;D |
Author: | munt4life [ Sun Dec 26, 2010 2:51 pm ] |
Post subject: | How can i get my code not to flacker?;D |
var x, y : int var top, bottom, left, right : boolean := false x := 100 y := 100 var chars : array char of boolean loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) and (y < 375) then y := y + 5 if y = 370 then top := true end if end if if chars (KEY_RIGHT_ARROW) and (x < 615) then x := x + 5 if x=610 then right:=true end if end if if chars (KEY_LEFT_ARROW) and (x > 0) then x := x - 5 if x=0 then left:=true end if end if if chars (KEY_DOWN_ARROW) and y > 0 then y := y - 5 if y=0 then bottom:=true end if end if if top = true then drawline (0, maxy, maxx, maxy, red) end if if bottom = true then drawline(0,0,maxx,0,red) end if if left= true then drawline(0,0,0,maxy,red) end if if right= true then drawline(maxx,0,maxx,maxy,red) end if drawbox (x, y, 20 + x, 20 + y, red) delay (10) cls |
Author: | Insectoid [ Sun Dec 26, 2010 3:20 pm ] |
Post subject: | RE:How can i get my code not to flacker?;D |
Use the site's search function. There are lots of tutorials on this, all of which tell you the same thing. |
Author: | ProgrammingFun [ Sun Dec 26, 2010 3:21 pm ] | ||||
Post subject: | Re: How can i get my code not to flacker?;D | ||||
EDIT: I didn't notice that Insectoid already posted ![]() You should try to use View.offscreenonly (I have forgotten if it looked exactly like that) to draw the shapes...this would diminish the flickering. Please try to use the given template when posting questions and plz also try to use syntax tags like the following:
so that you code would appear as follows:
|
Author: | munt4life [ Sun Dec 26, 2010 3:34 pm ] |
Post subject: | RE:How can i get my code not to flacker?;D |
I have but i still cant seem to get it to work ![]() |
Author: | ProgrammingFun [ Sun Dec 26, 2010 5:37 pm ] | ||||
Post subject: | RE:How can i get my code not to flacker?;D | ||||
The following was taken from the Turing FAQ: TheOneTrueGod @ Sun Jun 04, 2006 9:19 am wrote: Q: Why is my program flickery?
Ans: You aren't using View.Set ("offscreenonly") and View.Update or you aren't using them properly. The order of code should be as follows:
If "offscreenonly" is not spelled right, it will not work. Generally, if you have more than one View.Update, you're using it wrong. (This includes if you have it inside a for loop somewhere) An explanation: View.Set('offscreeonly') will initiate double buffering. This means Turing will draw everything to a "back buffer", which is invisible, elsewhere. Its an 'imaginary' piece of space somewhere in memory. You will never see what is being drawn there until you 'flip' it onto the screen, using View.Update. "View.Update" copies the entire back buffer to the front buffer, where it becomes visible in the Turing run window. This is why, when you use offscreenonly, you cannot see what you are writing when you use the command "get". To remedy the "I can't see what I'm inputting" problem, simply reset offscreenonly by using
|
Author: | SS1389 [ Sun Dec 26, 2010 6:09 pm ] |
Post subject: | Re: How can i get my code not to flacker?;D |
Very nice way to utilize your resources. |
Author: | ProgrammingFun [ Sun Dec 26, 2010 6:25 pm ] |
Post subject: | Re: How can i get my code not to flacker?;D |
SS1389 @ Sun Dec 26, 2010 6:09 pm wrote: Very nice way to utilize your resources. Indeed...that was the point ![]() |