[fpc-devel] Coding Questions

Tomas Hajny XHajT03 at mbox.vol.cz
Sat Dec 3 12:44:02 CET 2005


From:           	"VisionForce" <webmaster at visionforceweb.com>
To:             	"FreePascal Developer" <fpc-devel at lists.freepascal.org>
Date sent:      	Thu, 1 Dec 2005 21:26:49 -0600
Subject:        	[fpc-devel] Coding Questions
Send reply to:  	FPC developers' list <fpc-devel at lists.freepascal.org>
	<mailto:fpc-devel-request at lists.freepascal.org?subject=unsubscribe>
	<mailto:fpc-devel-request at lists.freepascal.org?subject=subscribe>

> I have some coding questions:
> 
> 1. Is there a synchronous readkey function, instead of that
> asynchronous one? I'm trying to make a simple game to help me learn
> Pascal, but I got stuck on this. I know that Turbo Pascal 7 has the
> synchronous readkey, but isn't there a way to do this in normal
> Pascal?

Have a look at unit Keyboard (function PollKeyEvent).


> 2. How would I delay the movement of something? When I use Delay(250),
> it delays the whole program. In VB, I would write this:
 .
 .
> So what do I do? Oh, and I need this to be strictly Pascal if
> possible, not Delphi; and I'm using the Crt code, so it's a shell
> (command prompt style), not Windows forms.

One possible cross-platform solution for this (certainly not the only 
one, but probably fitting quite well here) would be to use function 
GetMsCount from unit Dos. Regardless of the exact value returned by 
this call, the difference of values provided by two calls to this 
function should always be equal to the amount of milliseconds between 
the two calls (or at least as close to this as the implementation for 
a particular platform allows).

Tomas



More information about the fpc-devel mailing list