The Special Objects - The Time
The time object is a very easy method of adding every, time is, etc. events in Jamagic.
It is not called the Timer object, as in MMF because the Timer is already an object in Jamagic.
To make a simple "Time is..." event:

oJAM = New JAM( );
oJAM.Storyboard.NewFrame( Startup1, Code1, End1 );
oJAM.Run( );

Function Startup1( ){ }
Function Code1( )
{
	If( oJAM.Time.FrameTimeIs( 7000 ) )
	{
		// This code will run without fail when the
		// frame time is 7 seconds (7000 milliseconds)
	}
}
Function End1( ){ }

As you may guess from the name, FrameTimeIs, you can check other times:

If( oJAM.Time.GameTimeIs( 7000 ) )
{
	// This code will run without fail when the
	// game time is 7 seconds
}

If( oJAM.Time.SystemTimeIs( 7000 ) )
{
	// This code will run without fail when the
	// computer has been turned on for 7 seconds
	// (not likley to ever happen, see below)
}

And other checks can be used:

If( oJAM.Time.FrameTimeOver( 7000 ) )
{
	// This code will run constantly after
	// 7 seconds
}

If( oJAM.Time.FrameTimeUnder( 7000 ) )
{
	// This code will run constantly for the
	// first 7 seconds
}

If( oJAM.Time.FrameTimeBetween( 7000, 8000 ) )
{
	// This code will run constantly between
	// 7 and 8 seconds
}

Of course, these can be used with Game time and System time too.
Alternatively, you can just retrieve the time and do your own checks:

If(oJAM.Time.FrameTime( ) > 7000 )
{
	// This code will run constantly after 7
	// seconds
}

FrameTimeIs( ... ) is recomended over FrameTime( ) == ... since exact times will rarely occur. FrameTimeIs gets around this problem through other methods.

Another very important time-based event is Every.

If( oJAM.Time.Every( 2000 ) )
{
	// This code will run every 2 seconds
	// from the start of the frame
}
If( oJAM.Time.Every( 2000, 5000 ) )
{
	// This code will run at 5 seconds into
	// the frame, then every 2 seconds after that.
}

Note that Every cannot be used with game time or system time.

Working with system times
System times are big. Very big. They are the number of milliseconds since the computer started. Because of this, it is pointless comparing them to a fixed number. System times are more commonly compared to a previous system time + a number.
So what's the point in them then? Well, there aren't many. Without JAM, system time is all you have access to, making it very useful. But with JAM, it's pretty pointless.


The Time object doesn't just show the game time, it can retreive the current second, minute, hour, day of week/month/year and loads more:

Milliseconds   = oJAM.Time.CurrentMillisecond( );
Seconds        = oJAM.Time.CurrentSecond( );
Minutes        = oJAM.Time.CurrentMinute( );
Hours          = oJAM.Time.CurrentHours( );
DayOfMonth     = oJAM.Time.CurrentDayOfMonth( );
DayOfWeek      = oJAM.Time.CurrentDayOfWeek( );
// Monday = 0. Can be checked with oJAM.Time.MONDAY, etc.
DayOfYear      = oJAM.Time.CurrentDayOfYear( );
Week           = oJAM.Time.CurrentWeek( );
// Week counting is from the first monday of the year (Week 1)
Month          = oJAM.Time.CurrentMonth( );
// January = 1. Can be checked with oJAM.Time.JANUARY, etc.
Year           = oJAM.Time.CurrentYear( );
IsLeapYear     = oJAM.Time.IsLeapYear( );
Is2000LeapYear = oJAM.Time.IsLeapYear( 2000 );
DaysInYear     = oJAM.Time.GetDaysInYear( );
DaysInYear2000 = oJAM.Time.GetDaysInYear( 2000 );

And finally, you can retreive the time the user has been idle for (not moved the mouse / pressed a key)

IdleFor = oJAM.Time.GetIdleFor( );
// or:
IsIdleFor3Seconds = oJAM.Time.HasBeenIdleFor( 3000 );

That's it :-)

BACK TO OVERVIEW



JAM © 2005 no one in particular
Project started by David Evans in 2005