Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i write text on top of another game ?

Status
Not open for further replies.

DKQuane

Programmer
Feb 15, 2004
2
DK
Hello. I need to make a timer, to see how long of the game has elapsed, that shows the timer in the top left corner. Eventually it should be able to start, restart and stop when i push etc. "ALT+s" and so on.
How do i create that ? We're talking about Starcraft.

Hope you can help, please resond to my mail quane666@hotmail.com :)

Thanks
-Quane
 
Place a TTimer on your form (System tab of component palette).

Use the OnTimer event to update your clock. You will need to keep a separate counter somewhere.

Toggle the TTimer.Enables from your ALT-S trap.

With the above when you stop and restart the time, it will start again from the beginning of its time interval. You may get better accuracy by using the Time function in every timer and ALT-S event, rather than relying on your own counter.

Have fun
Simon

PS. The point of a newsgroup is that you ask an intelligent question, someone answers and EVERYONE benefits. So no reply to your private e-mail.
 
Well, thanks for the answer but the timer is no problem. The problem for me is to get the timer shown on my game. In game. I was wondering if someone has an easy suggestion ? I don't know about Direct Draw, OpenGL and so on.
 
DKQuane,
Are you the author of the game? Do you need code for the timer to display like a clock in the corner of your window or in a seperate window?
for a clock like display of hh:mm:ss follow these steps
you'll need 3 threads/timers named seconds, minutes, hours. The first thread/timer called seconds will count and trigger every 1000 ms.i.e every second.
you will check for when it (seconds timmer) counts to 59 so that in its on timer event will call/ activate the minutes thread.(i.e enable minutes)
You will set minutes to trigger every 60*1000 ms (i.e every minute)
You will check when this (minutes)counts to 59 to trigger the hours thread.
You will set the third thread / timer to triger ever hour i.e 1000*60*60.
You will check for when the hours thread reaches 24 or 12 depending on the clock display you want.
Each ontimer event for seconds will update the caption of a label i.e label1.caption := inttostr(x) where x is the current value of the timer's per second count. This is so because in each on timer event, you state that x := x+1;//increment.
if x = 59 then x := 1; //reset;
You follow the above for each thread.
**********
Try the above. Tomorrow I will develop the code for you if this is what you need.
The captions to display the clock could be on a panel for easy display. The panel can then be made visible or invisible which has the effect of hiding or showing the clock.
I hope this helps and please indicate if you need the code.
Yomi.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top