2 registered members (henrybane, 1 invisible),
775
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Show minutes and seconds
[Re: WretchedSid]
#351010
12/20/10 23:44
12/20/10 23:44
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
I'd just use a timer function for a timer...
#include <acknex.h>
#include <default.c>
long lng_total;
var var_secs;
var var_mins;
var var_hours;
FONT* fnt_timer = "arial#24";
PANEL* pnl_timer = {
digits( 60, 60, "%02.0f", fnt_timer, 1, var_mins);
digits(100, 60, "%02.0f", fnt_timer, 1, var_secs);
flags = SHOW;
}
void restart_timer(){
proc_mode = PROC_LATE;
lng_total = 0; //nanoseconds set to something to speed up time (55000 55seconds)
timer();
}
void main(){
timer();
on_mouse_left = restart_timer;
while(1){
lng_total += timer() / 1000;
var_secs = integer((lng_total / 1000) % 60);
var_mins = integer((lng_total / 1000) / 60);
wait(1);
}
}
|
|
|
Re: Show minutes and seconds
[Re: MrGuest]
#351033
12/21/10 07:02
12/21/10 07:02
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Too bad that timer doesn't work between two frames, right? I srsly don't know why you all think you'd need to put out a minigun to destroy everything helpful on you way.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Show minutes and seconds
[Re: WretchedSid]
#351047
12/21/10 11:50
12/21/10 11:50
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Too bad that timer doesn't work between two frames, right? I srsly don't know why you all think you'd need to put out a minigun to destroy everything helpful on you way. lol, not really a minigun but just a way to offer a precision timer... your way only offers precision to a 16th of a second. Also you'll need to convert seconds and minutes to an integer otherwise they'll be added when they're 0.5 or over What do you mean that timer doesn't work between two frames?
|
|
|
Re: Show minutes and seconds
[Re: WretchedSid]
#351090
12/21/10 19:32
12/21/10 19:32
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Rojart, thats evil because you assume that the user always has 60 frames per seconds. JustSid, I see no problem to change the fps like this:
#include <default.c>
#define PRAGMA_PATH "%EXE_DIR%\samples"
#define FPS 68 // Frames per seconds can be changed individually
var seconds, minutes = -1;
FONT* A20b = "Arial#20b";
PANEL* pInfo;
function main()
{
fps_max = FPS;
level_load ("small.hmp");
vec_set(camera.x, vector(0,0,150));
pInfo = pan_create(NULL,0);
pan_setdigits(pInfo,0,10,10,"SECONDS = %.0f", A20b, 1, seconds);
pan_setdigits(pInfo,0,10,30,"MINUTES = %.0f", A20b, 1, minutes);
set(pInfo, OUTLINE|SHOW);
while(level_ent)
{
if ((total_frames % FPS) == 1) seconds++;
if ((total_frames % (FPS*60)) == 1) minutes++;
wait(1);
}
}
|
|
|
Re: Show minutes and seconds
[Re: rojart]
#351167
12/22/10 14:02
12/22/10 14:02
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
#define FPS 68 // Frames per seconds can be changed individually
I really hope that you just tried to be funny. What do you mean that timer doesn't work between two frames?
Look into the manual into the timer function. Oh and my approach is 100% precise as long as time_frame is precise (which it really should be), it multiplied by 16 to get the seconds with miliseconds needed for the drawing. And another thing: Casting into an integer (not via the integer() function but with a plain (int)) is much faster than an expensive multiplication that needs at least four processor cycles to finish.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Show minutes and seconds
[Re: Minamato]
#351368
12/23/10 22:26
12/23/10 22:26
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Instead of adding the delta time, subtract it from a variable with a value of 300 (5 * 60 seconds). When the variable is <= 0.0f, the five minutes passed.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
|