#include <Replay.h>
Public Member Functions | |
| Replay (char *file) | |
| Replay (int timeStepMs) | |
| ~Replay () | |
| void | readUpdate (Level2D *l) |
| void | writeUpdate (Level2D *l) |
Static Public Member Functions | |
| static int | getLastIndex () |
Public Attributes | |
| ReplayMode | mode |
| int | timeStepMs |
| bool | replayReachedPortal |
| int | lastIndex |
| bool | replayEnded |
Represents a single game replay saved in raw / binary data. The replay is saved in a replay file. Replay files are raw data with a fixed timeStep at which the data is written or read. The raw data consists of Player::x, Player::y, Player::rotation, Level::playerReachedPortal, Level::playerHasObstacleBeforePortal. There are two modes for a replay object: REPLAY_MODE_READ and REPLAY_MODE_WRITE. The application playing or recording replays must ensure that the timeStep is handled correctly.
REPLAY_MODE_WRITE:
A replay searches for the file "replay/lastReplayIndex.txt" to determine which was the last replay file. Replay files are named only by numbers. If the file is not found the replay is named "1".
Correct replay file format:
=============================================
sonus replay file
timeStepMS
<time step="" in="" milliseconds>="">
level data
<Player::x>
<Player::y>
<Player::rotation>
<Level::playerReachedPortal>
<Level::playerHasObstacleBeforePortal>
<Player::x>
<Player::y>
<Player::rotation>
<Level::playerReachedPortal>
<Level::playerHasObstacleBeforePortal>
...
filename: Replay.h
| sonus::Replay::Replay | ( | char * | file | ) |
Constructor for reading replays (REPLAY_MODE_READ)
| file | replay file to read |
| sonus::Replay::Replay | ( | int | timeStepMs | ) |
Constructor for writing replays (REPLAY_MODE_WRITE)
| timeStepMS | time step in milliseconds |
| sonus::Replay::~Replay | ( | ) |
Destructor
| static int sonus::Replay::getLastIndex | ( | ) | [inline, static] |
Returns the index of the last replay file.
| void sonus::Replay::readUpdate | ( | Level2D * | l | ) |
This function is for reading replays. Every time you need to update the level you call this function. Data is read directly from the file.
| l | level in which data is read |
| void sonus::Replay::writeUpdate | ( | Level2D * | l | ) |
This function is for writing replays. Every time you need to update the replay you call this function. Data is written directly to the file.
| l | level which is written to file |
1.5.4