This wiki is out of date, use the continuation of this wiki instead

Timer

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 18:35, 27 December 2007 (edit)
Sandman (Talk | contribs)
(New page: category:variables category:predefined category:global variables '''Up to Global Variables''' ---- == Definition == '''INT[9]''' timer '''Timer''' is ...)
← Previous diff
Revision as of 18:37, 27 December 2007 (edit) (undo)
Sandman (Talk | contribs)
m (Definition)
Next diff →
Line 11: Line 11:
'''INT[9]''' timer '''INT[9]''' timer
-'''Timer''' is a [[global variable]], holding ten integers. Each frame a certain value is added to all of them. This value is about the time it took to build the last frame, in 1/100 seconds.+'''Timer''' is a [[global variable]], holding ten integers. Each frame a certain value is added to all of them. This value is the time it took to build the last frame, in 1/100 seconds.
 + 
 +So when timer[0] is never altered, its value will be about 1234 when the program has been running for 12.34 seconds.
== Example == == Example ==

Revision as of 18:37, 27 December 2007

Up to Global Variables



Definition

INT[9] timer

Timer is a global variable, holding ten integers. Each frame a certain value is added to all of them. This value is the time it took to build the last frame, in 1/100 seconds.

So when timer[0] is never altered, its value will be about 1234 when the program has been running for 12.34 seconds.

Example

Display how long the program has been running:

Private
    int ft; // Help variable
    int i;  // how long the program has been running in 1/100s
    float f; // how long the program has been running in 1/100s
Begin

    set_mode(320,400,8);
    write_int   (0,0,300,0,&timer);
    write_int   (0,0,310,0,&i);
    write_float (0,0,320,0,&f);

    Repeat

        // Calculate how long the program has been running in 1/100s without a float
        ft %= 10; // keep the milliseconds from last time
        ft += frame_time*1000; // add the last passed time to it in milliseconds
        i += ft/10; // add it to the integer without the milliseconds

        // Calculate how long the program has been running in 1/100s with a float
        f+=frame_time*100;

        frame;
    Until(key(_ESC))

End

Let a process wait for a certain time by calling this function:

Function int wait(int t)
Begin
    t += timer[0];
    While(timer[0]<t) frame; End
    return t-timer[0];
End

This can be done without a timer too, as is displayed here.


Global variables
ArgcArgvCdinfoDump_typeFadingFileinfoFpsFrame_timeFull_screenGraph_modeMouseOs_idRestore_typeScale_modeScrollSound_channelsSound_freqSound_modeText_flagsText_zTimer
Personal tools