More specs

2025-08-09 18:01:16 +02:00
parent f27067b585
commit 9ea5cd3fd1
4 changed files with 134 additions and 1 deletions

@@ -0,0 +1,21 @@
# ModuleApi - GameLib FrameCycle
Simple object used to perform time calculations for sychronized rendering across clients.
## Structure
```JSON
{
"startTimestamp": 1754754260809,
"frameInterval": 1000 / 60,
"totalFrames": 10
}
```
| Attribute | Type | Description |
| --------------------- | ------ | ------------------------------------------------------- |
| startTimestamp | number | The start timestamp of the frame cycle in milliseconds. |
| frameInterval | number | The interval between frames in milliseconds. |
| totalFrames | number | The total number of frames in the cycle. |
| (Optional) startFrame | number | The start frame of the cycle. |

@@ -0,0 +1,18 @@
# ModuleApi - GameLib TimeSpan
Simple object used to perform time calculations for sychronized rendering across clients.
## Structure
```JSON
{
"startTimestamp": 1754754260809,
"endTimestamp": 1754754270809
}
```
| Attribute | Type | Description |
| -------------- | ------ | ------------------------------------ |
| startTimestamp | number | The start timestamp of the TimeSpan. |
| endTimestamp | number | The end timestamp of the TimeSpan. |

@@ -17,20 +17,112 @@ api.GameLib.newController(roomId, controllerId);
| roomId | string | The ID of the game room. | | roomId | string | The ID of the game room. |
| controllerId | string | The ID of the controller. | | controllerId | string | The ID of the controller. |
**Return** [Controller](./ModuleClientAPIGameLibController) _The GameLib Controller_ **Return** [Controller](./ModuleClientAPIGameLibController) _Controller instance._
## Timing ## Timing
Several functions to synchronize clients using the synced time you can retrieve using `api.getTime()`.
### toTimeSpan ### toTimeSpan
Creates a timespan object.
```javascript
api.GameLib.Timing.toTimeSpan(duration, startTimestamp?);
```
| Argument | Type | Description |
| ------------------------- | ------ | ---------------------------------------------------- |
| duration | number | The duration of the timespan in milliseconds. |
| (Optional) startTimestamp | number | The start timestamp of the timespan in milliseconds. |
**Return** [TimeSpan](./ModuleApiGameLibTimeSpan) _TimeSpan instance._
### toFrameCycle ### toFrameCycle
Creates a frame cycle object.
```javascript
api.GameLib.Timing.toFrameCycle(startTimestamp, frameInterval, totalFrames, startFrame?);
```
| Argument | Type | Description |
| -------------- | ------ | ------------------------------------------------------- |
| startTimestamp | number | The start timestamp of the frame cycle in milliseconds. |
| frameInterval | number | The interval between frames in milliseconds. |
| totalFrames | number | The total number of frames in the cycle. |
| startFrame | number | The start frame of the cycle. |
**Return** [FrameCycle](./ModuleApiGameLibFrameCycle) _FrameCycle instance._
### getCurrentFrameIndex ### getCurrentFrameIndex
Gets the current frame index of the frame cycle.
```javascript
api.GameLib.Timing.getCurrentFrameIndex(cycle);
```
| Argument | Type | Description |
| -------- | ------------------------------------------ | ------------------- |
| cycle | [FrameCycle](./ModuleApiGameLibFrameCycle) | FrameCycle instance |
**Return** number _The current frame index._
### getFrameIndexAtTimestamp ### getFrameIndexAtTimestamp
Gets the current frame index of the frame cycle.
```javascript
api.GameLib.Timing.getFrameIndexAtTimestamp(cycle, timestamp);
```
| Argument | Type | Description |
| --------- | ------------------------------------------ | ---------------------------------------- |
| cycle | [FrameCycle](./ModuleApiGameLibFrameCycle) | FrameCycle instance |
| timestamp | number | The timestamp to get the frame index at. |
**Return** number _The frame index at the given timestamp._
### getCurrentTimeSpanRatio ### getCurrentTimeSpanRatio
Gets the ratio of the current time span.
```javascript
api.GameLib.Timing.getCurrentTimeSpanRatio(span);
```
| Argument | Type | Description |
| -------- | -------------------------------------- | ----------------- |
| span | [TimeSpan](./ModuleApiGameLibTimeSpan) | TimeSpan instance |
**Return** [Ratio](./ModuleApiGameLibRatio) _The ratio of the current time span._
### getTimeSpanRatioAtTimestamp ### getTimeSpanRatioAtTimestamp
Gets the ratio of the time span at the given timestamp.
```javascript
api.GameLib.Timing.getTimeSpanRatioAtTimestamp(span, timestamp);
```
| Argument | Type | Description |
| --------- | -------------------------------------- | ---------------------------------- |
| span | [TimeSpan](./ModuleApiGameLibTimeSpan) | TimeSpan instance |
| timestamp | number | The timestamp to get the ratio at. |
**Return** [Ratio](./ModuleApiGameLibRatio) _The ratio of the time span at the given timestamp._
### toRatio ### toRatio
Creates a ratio object.
```javascript
api.GameLib.Timing.toRatio(value);
```
| Argument | Type | Description |
| -------- | ------ | ----------------------- |
| value | number | The value of the ratio. |
**Return** [Ratio](./ModuleApiGameLibRatio) _Ratio instance._

@@ -26,6 +26,8 @@
- ModuleApi Shared - ModuleApi Shared
- [GameLib GameDetails](./ModuleApiGameLibGameDetails) - [GameLib GameDetails](./ModuleApiGameLibGameDetails)
- [GameLib EndScreen](./ModuleAPIGameLibEndScreen) - [GameLib EndScreen](./ModuleAPIGameLibEndScreen)
- [GameLib TimeSpan](./ModuleApiGameLibTimeSpan)
- [GameLib FrameCycle](./ModuleApiGameLibFrameCycle)
- [Module Debugging](./ModuleDebugging) - [Module Debugging](./ModuleDebugging)
- [ModuleStore](./ModuleStore) - [ModuleStore](./ModuleStore)
- [Bug/Feature Reporting](./Reporting) - [Bug/Feature Reporting](./Reporting)