How to make a counter

Game Editor comments and discussion.

How to make a counter

Postby Clokio » Tue Jun 21, 2011 7:52 pm

I want a counter that will count how long the game is started.
:mrgreen:
Thanks
Clokio
 
Posts: 229
Joined: Tue May 17, 2011 2:18 pm
Score: 32 Give a positive score

Re: How to make a counter

Postby skydereign » Tue Jun 21, 2011 8:27 pm

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++;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How to make a counter

Postby Clokio » Tue Jun 21, 2011 9:03 pm

thanks :D , is there one independant of the frame rate, cause FPS can change.
Clokio
 
Posts: 229
Joined: Tue May 17, 2011 2:18 pm
Score: 32 Give a positive score

Re: How to make a counter

Postby skydereign » Tue Jun 21, 2011 9:55 pm

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest