Page 1 of 1

How to make a counter

PostPosted: Tue Jun 21, 2011 7:52 pm
by Clokio
I want a counter that will count how long the game is started.
:mrgreen:
Thanks

Re: How to make a counter

PostPosted: Tue Jun 21, 2011 8:27 pm
by skydereign
Well, there is a variable that holds how many frames have passed. If you wanted to know seconds for instance (assuming a 30fps game), do this.
Code: Select all
textNumber=frame/30;


If that isn't what you want, you'd have to create a variable, and in the view's draw actor do this (of course this is the same as using frame, so you'd have to change it to increment however often you wanted it to).
Code: Select all
game_timer++;

Re: How to make a counter

PostPosted: Tue Jun 21, 2011 9:03 pm
by Clokio
thanks :D , is there one independant of the frame rate, cause FPS can change.

Re: How to make a counter

PostPosted: Tue Jun 21, 2011 9:55 pm
by skydereign
Well, you can set a definition that is equal to the fps.
Global Code
Code: Select all
#define fps 30


You could also use another variable that is built in, if using the real fps will work (accounts for lag). If so, gE provides a variable real_fps.
Code: Select all
textNumber=frame/real_fps;