Computer Science Canada

Help me on Records and Forks please

Author:  ohgeez_ [ Thu Apr 20, 2006 9:28 pm ]
Post subject:  Help me on Records and Forks please

I've heard that forks should be avoided at all costs in acception to music but if i don't use forks, then how do I make two objects move at the same time?

I know that using both objects in the same loop would make the move at the same time but what if one of the object moving is based on an input from the user? Say i use 'getch' , the computer will always wait for the input before continuing on in the loop. This stops my other object from moving.

I heard some people say that it's possible to do it with records, is it possible? If so how?

Author:  [Gandalf] [ Thu Apr 20, 2006 9:49 pm ]
Post subject:  Re: Help me on Records and Forks please

ohgeez_ wrote:
Say i use 'getch' , the computer will always wait for the input before continuing on in the loop. This stops my other object from moving.

No, it shouldn't prevent your loop from continuing if there is no key input. Both Input.KeyDown() and getch() work nearly the same, and we have a few tutorials on each:
http://www.compsci.ca/v2/viewtopic.php?t=114
http://www.compsci.ca/v2/viewtopic.php?t=3275
http://www.compsci.ca/v2/viewtopic.php?t=3270

And on records, in case you're interested. They are a very useful tool in Turing programming:
http://www.compsci.ca/v2/viewtopic.php?t=2325

For any extra help, consult the Turing Walkthrough.

Author:  Tony [ Thu Apr 20, 2006 9:55 pm ]
Post subject: 

if you insist on using getch() though, you could combine it with hasch

code:

if hasch then
   getch(c)
else
   % there's nothing waiting to be read, don't pause for getch
end if


: