Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (kzhao, AndrewAMD, bigsmack), 824 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
frames/seconds since function started? #298548
11/15/09 22:41
11/15/09 22:41
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hi, i'm wondering if there is a variable/function that gives you the frames or seconds past since a particular function was started.

Currently i'm using a local var and incrementing it each frame. I had a quick look through the manual but didn't find anything. Just asking in-case i may have missed it.

Thanks.

Re: frames/seconds since function started? [Re: DJBMASTER] #298570
11/16/09 03:48
11/16/09 03:48
Joined: Nov 2009
Posts: 34
S
Sepiantum Offline
Newbie
Sepiantum  Offline
Newbie
S

Joined: Nov 2009
Posts: 34
If you can write a timer, now is a good time.

Re: frames/seconds since function started? [Re: Sepiantum] #298615
11/16/09 13:59
11/16/09 13:59
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Nope, there is no such variable or function.

Re: frames/seconds since function started? [Re: Lukas] #298625
11/16/09 14:58
11/16/09 14:58
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
you got those functions only for the game itself

total_frames & total_ticks


"empty"
Re: frames/seconds since function started? [Re: flits] #298644
11/16/09 17:21
11/16/09 17:21
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
a better way than to increment that thing would, in my oppinion, be:
Code:
void theFunction()
{
  var startingTicks = total_ticks;
  var ticksPassedSinceStart;
  while(1)
  {
    //do something
    if(blah)
    {
      ticksPassedSinceStart = total_ticks - startingTicks;
    }
    wait(1);
  }
}




~"I never let school interfere with my education"~
-Mark Twain
Re: frames/seconds since function started? [Re: Germanunkol] #298664
11/16/09 19:06
11/16/09 19:06
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hmmm, i'm trying to find the simplest solution that can accomodate for both frames and seconds. Here is my code so far...
Code:
var alarm_timer = 0;

while(1)
{
if(alarm_timer == 10) // after 10 frames have passed
{
  beep();
}
if(alarm_timer == 20) // after 20 frames have passed
{
  beep();
}

alarm_timer += time_step; // or time_frame?
wait(1);
}



But this is buggy, because it sometimes beeps and sometimes doesn't. I think i may be getting confused with time_step and time_frame. I'm not 100% sure what the difference is between them.

Last edited by DJBMASTER; 11/16/09 19:07.
Re: frames/seconds since function started? [Re: DJBMASTER] #298665
11/16/09 19:09
11/16/09 19:09
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
you can't be sure that if you add time_step, that it is exactly 10 or 20 because time_step is usually between 0.2 - 0.5 .

If you want frames, just add "1"

Re: frames/seconds since function started? [Re: Rei_Ayanami] #298666
11/16/09 19:42
11/16/09 19:42
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
yeh ok, i guess i can sort it out for frames, by just doing a 'alarm_timer++;". What about for seconds? Can i just do a calculation on the same variable - alarm_timer? I want to stick to using the minimum amount of variables necessary.

Something to do with a division or multiplication by 16?

Thanks for your help.

Re: frames/seconds since function started? [Re: DJBMASTER] #298667
11/16/09 19:52
11/16/09 19:52
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
For seconds, add time_step/16 each frame.

Re: frames/seconds since function started? [Re: Lukas] #298668
11/16/09 20:01
11/16/09 20:01
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Originally Posted By: Lukas
For seconds, add time_step/16 each frame.


Yeh i originally tried that but it doesn't always work when using it in a comparison statement...
Code:
var alarm_timer = 0;
while(1)
{
if(alarm_timer == 5) // after 5 seconds
{ 
beep();
}
alarm_timer += time_step / 16;
wait(1);
}



It seems to only work sometimes, and not 100% of the time.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1