Computer Science Canada Delay without the Delay O.o |
Author: | Warchamp7 [ Wed Jun 13, 2007 12:57 pm ] | ||||
Post subject: | Delay without the Delay O.o | ||||
Is it possible to make the arrow keys recieve a delay when being pushed down. I currently have a loop that constantly updates the screen but I want the arrow keys to have some sort of delay.
Interface is the procedure that draws everything. How can I incorporate arrow keys into this so that they don't change my variable value so fast:
Basically, it's a menu with 4 options, it checks if when pressing up, if the option is 1, to go to the bottom to number 4, etc I want a delay between the movement so it doesn't scroll from 1 to 4 in a split second, while still maintaining the "Drawing" loop working constantly |
Author: | SNIPERDUDE [ Wed Jun 13, 2007 1:45 pm ] | ||
Post subject: | Re: Delay without the Delay O.o | ||
yes it is possible, but it requires a bit of coding. All you need to do is create a for loop (in a procedure) that counts how ever many times you want (so the proc is called every time the prog cycles through the loop) and have a boolean that resets after the loop is done; so the user can only press the button every time the counter resets. For Example:
|
Author: | Clayton [ Wed Jun 13, 2007 1:55 pm ] |
Post subject: | RE:Delay without the Delay O.o |
So what happens on a really slow system? Instead, look into using Time.Elapsed(). |
Author: | Albrecd [ Wed Jun 13, 2007 8:34 pm ] |
Post subject: | Re: Delay without the Delay O.o |
Or you could always put the action in a process and fork it when the button is pressed. Then you can have a delay in the process and it won't affect your background. That's right, I said process |
Author: | Cervantes [ Wed Jun 13, 2007 10:58 pm ] |
Post subject: | RE:Delay without the Delay O.o |
Don't even joke about such things! |
Author: | Carey [ Thu Jun 14, 2007 9:05 am ] |
Post subject: | Re: Delay without the Delay O.o |
Processes are evil. I admit it is sometimes the best way, but only for something that is non-critical to the execution of the program, like drawing a non-improtant graphic. |
Author: | Dan [ Thu Jun 14, 2007 9:21 am ] |
Post subject: | Re: Delay without the Delay O.o |
Carey @ 14th June 2007, 9:05 am wrote: Processes are evil. I admit it is sometimes the best way, but only for something that is non-critical to the execution of the program, like drawing a non-improtant graphic.
Only if you don't care when thos graphics are drawn. With turings limited to no control to syncrioize process execution you basically will have graphics that draw at random times (unless you understand process enought to make your own syncoriztion system). With most projects peoleop are doing in truing process are relay not needed and it gets them in to bad habits. Process == bad with out synchronization of some kind. |
Author: | Warchamp7 [ Thu Jun 14, 2007 9:05 pm ] |
Post subject: | RE:Delay without the Delay O.o |
Quote: Processes are evil. I admit it is sometimes the best way, but only for something that is non-critical to the execution of the program, like drawing a non-improtant graphic.
Exactly lol XD But your idea sounds good Sniper, I'll give it a shot =D |
Author: | rizzix [ Fri Jun 15, 2007 12:32 am ] |
Post subject: | RE:Delay without the Delay O.o |
Concurrency requires a different mindset (something most of us are not really used to). You need to know exactly what you can put in a different thread and what you should avoid running concurrently. For most cases you don't really need it. And yes as Dan said, synchronization is the key. (This is a tricky task specially since you need to avoid the "deadlock") |