comp.lang.ada
 help / color / mirror / Atom feed
From: Dr Nancy's Sweetie <kilroy@elvis.rowan.edu>
Subject: On-Screen Elapsed Time Display?
Date: Fri, 11 Oct 2002 18:54:36 GMT
Date: 2002-10-11T18:54:36+00:00	[thread overview]
Message-ID: <M7Fp9.19408$T_.451626@iad-read.news.verio.net> (raw)

I searched Google a few times for this, and didn't seem to find it,
but maybe I just couldn't think of the Right Magic Keywords.  So
this is probably a stupid newbie question that's been answered 100
times.  (Maybe the next person to search on the keywords I came up
with will find this article and the helpful replies.)

I have written a game, and thought it might be more interesting with
"best times" file, so people can compete with each other.  It's
easy enough to add in something like this:

   type Time_T is new Long_Integer;
   Start_Time, Win_Time: Time_T;
   procedure Time ( Time : in out Time_T);
   pragma Import (C, Time);

and then set Win_Time when the player wins, subtract, and figure out
how long it took.

What I don't see easily (and maybe I'm just blind) is a good way to
get a display on the screen (the game uses ncurses) during play.
I can update the clock every time someone pushes a key, of course,
but that's kinda lame.

What I probably need is some Ada version setitimer().  Then it's
just a matter of set up a function that displays the clock, hook the
function to SIGALRM, and set the timer to 900ms.  I found the pragma
"Attach_Handler", and also found SIGALRM in Ada.Interrupts.Names.
But what's the Ada equivalent of "setitimer();"?

I can import setitimer(), and make Ada versions of struct timerval
and itimerval, but that's starting to feel like I'm overusing C,
and depending on Unixisms (which is bad for portability).

What is the Right Thing to do?  I'm using GNAT, if that makes any
difference.


Thanks,
Darren

Darren Provine ! kilroy@elvis.rowan.edu ! http://www.rowan.edu/~kilroy
"Everybody writes that we have no chance, but, you know, the horse can't
 read." -- Wilson Brown, trainer of Kentucky Derby entry It'sallinthechase,
           May 2002  (odds 50-1 against)



             reply	other threads:[~2002-10-11 18:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-11 18:54 Dr Nancy's Sweetie [this message]
2002-10-11 19:32 ` On-Screen Elapsed Time Display? Jeffrey Carter
2002-10-14 21:36   ` Dr Nancy's Sweetie
2002-10-14 23:05     ` tmoran
2002-10-16  1:45       ` Dr Nancy's Sweetie
2002-10-15 19:23   ` Dr Nancy's Sweetie
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox