Time: Difference between revisions
| Line 17: | Line 17: | ||
=== Set Time === | === Set Time === | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="c">settime {int time} | ||
settime {int time} | |||
#default | #default | ||
settime 99 | settime 99</syntaxhighlight>Level header command that sets value applied to timer on level start and native resets. | ||
</syntaxhighlight>Level header command that sets value applied to timer on level start and native resets. | |||
* Accepts any integer value from <code>0</code> to <code>99</code>. Out of bounds values are ignored. | * Accepts any integer value from <code>0</code> to <code>99</code>. Out of bounds values are ignored. | ||
Revision as of 13:15, 12 July 2026
Introduction
Timing is crucial to OpenBOR, as it is with most game engines. Understanding how the engine measures time, and how those measurements affect a project, is therefore essential. OpenBOR’s primary unit of time is the centisecond, or one hundredth of a second. Animation delays, for example, are expressed in centiseconds. Other units may be used depending on the feature, circumstance, or design requirement.
Time in OpenBOR is represented by the following primary definitions:
Game Time – The traditional beat ’em up countdown timer that forces players to maintain pace or lose a life when time expires. Game Time is enabled by default, though creators may disable or remove it.
Elapsed Time – An integer value reset at the beginning of each active level and incremented on every engine update while the level remains active. Elapsed Time drives much of the engine’s internal timing, including animations, delays, effect duration, and other game-play processes.
Ticks – The number of milliseconds elapsed since the current game session began. Tick values are primarily used for timing operations outside active game-play, including loading processes and recorded player input.
System Time - OpenBOR script includes an API to access the host system clock for obtaining real-world dates and times. System clock access is entirely optional and does not affect native engine timing or game-play functionality.

Game Time
Game time is a default countdown timer that appears at top center of the screen during an active level. It starts at 99 and decrements once every two real world seconds. At 0, all active players take damage equal to their current HP, and the game is over if no lives or credits remain. Time resets automatically when players clear a designated level wait and at the start of each new level.

Set Time
settime {int time}
#default
settime 99
Level header command that sets value applied to timer on level start and native resets.
- Accepts any integer value from
0to99. Out of bounds values are ignored. 0= infinite time.
HUD Display
For configuring how timer displays on screen, see Heads Up Display.
Other
data/sounds/timeover.wav
If available, plays once when the game timer expires.
anim lose
If available, entity plays this animation in place of normal death when game timer expires.
- Accessible to script as
openborconstant("ANI_LOSE").
anim falllose
If available and entity does not have a lose animation, entity plays this animation in place of normal fall death when game timer expires.
- Accessible to script as
openborconstant("ANI_FALLLOSE").
Attack types
Attack types applied to players when game time expires.
- openborconstant("ATK_TIMEOVER") - Applied to players without a lose animation.
- openborconstant("ATK_LOSE") - Applied to players with a lose animation.
Script API
Game Time
Current game time is read and write accessible.
Get
int time = openborvariant("game_time");
Get integer representing game time remaining.
Set
int new_time = 50;
setopenborvariat("game_time", new_time);
Set game time remaining.
Timetick Event
If available, data/scripts/timetick.c fires on each game time decrement. Populates the following local variables.
time- Current game time value.
Ticks
Ticks is a read only measure of milliseconds starting from game boot. OpenBOR natively uses ticks for the player input recording feature and for timing during load screens. Ticks therefore do not generally affect active game-play, but are useful for user content, scripting, and keeping time outside of active game-play elements when increments are not natively incremented.
openborvariant("ticks")- Get integer milliseconds from game boot.