sonus::Replay Class Reference

#include <Replay.h>

List of all members.

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


Detailed Description

sonus::Replay

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

Date:
2008/04/27 18:09
Author:
Alexander Lawrence
Version:
1.0

Constructor & Destructor Documentation

sonus::Replay::Replay ( char *  file  ) 

Constructor for reading replays (REPLAY_MODE_READ)

Parameters:
file replay file to read

sonus::Replay::Replay ( int  timeStepMs  ) 

Constructor for writing replays (REPLAY_MODE_WRITE)

Parameters:
timeStepMS time step in milliseconds

sonus::Replay::~Replay (  ) 

Destructor


Member Function Documentation

static int sonus::Replay::getLastIndex (  )  [inline, static]

Returns the index of the last replay file.

Returns:
last replay index

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.

Parameters:
l level in which data is read
Warning:
only use this function if the replay object was constructed with REPLAY_MODE_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.

Parameters:
l level which is written to file
Warning:
only use this function if the replay object was constructed with REPLAY_MODE_WRITE


The documentation for this class was generated from the following file:
Generated on Tue Aug 26 12:26:54 2008 for sonus by  doxygen 1.5.4