I'm trying to create a simple game in Pascal. It uses the console. The goal in the game is to collect as many 'apples' as you can in 60 seconds. The game structure is a simple infinite loop. Each iteration, you can make one move. And here's the problem — before you make the move (readKey
), time can pass as much as it wants. For example, the user can press a key after 10 seconds! Is there any way to count time? I need the program to know when user plays (before and after a key is pressed), so I don't know how to prevent user from "cheating".
Here's simple structure of my game:
begin
repeat
{* ... *}
case ReadKey of
{* ... *}
end;
{* ... *}
until false;
end.
Full code: http://non.dagrevis.lv/junk/pascal/Parad0x/Parad0x.pas.
As far I know that there are two possible solutions:
- getTime (from DOS),
- delay (from CRT).
...but I don't know how to use them with my loop.