Output replays
This commit is contained in:
parent
17c182f474
commit
2dfad249ad
3 changed files with 100 additions and 18 deletions
55
game.h
55
game.h
|
@ -357,8 +357,8 @@ char LCR_gameGetNextResourceStrChar(void)
|
|||
}
|
||||
|
||||
/**
|
||||
Seeks to the Nth resource string in the global resource file, after its name,
|
||||
so that the pure resource string will now be available for reading.
|
||||
Seeks to the Nth resource string in the global resource file, after the magic
|
||||
number, so that the name is now available for reading.
|
||||
*/
|
||||
void LCR_seekResourceByIndex(unsigned int index, char magicNumber)
|
||||
{
|
||||
|
@ -368,31 +368,45 @@ void LCR_seekResourceByIndex(unsigned int index, char magicNumber)
|
|||
|
||||
LCR_gameRewindResourceFile();
|
||||
|
||||
while (index)
|
||||
do
|
||||
{
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
|
||||
if (c == 0)
|
||||
return;
|
||||
|
||||
if (c == magicNumber)
|
||||
index--;
|
||||
|
||||
do
|
||||
{
|
||||
if (index)
|
||||
index--;
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
while (c != 0 && c != LCR_RESOURCE_FILE_SEPARATOR)
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
while (c != LCR_RESOURCE_FILE_SEPARATOR && c != 0);
|
||||
}
|
||||
|
||||
do // skip magic number and name
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
while (c != LCR_RESOURCE_FILE_SEPARATOR2 &&
|
||||
c != LCR_RESOURCE_FILE_SEPARATOR && c != 0);
|
||||
|
||||
} while (c);
|
||||
}
|
||||
|
||||
void LCR_gameStartRun(unsigned int mapIndex)
|
||||
{
|
||||
char mapName[LCR_MAP_NAME_MAX_LEN];
|
||||
|
||||
LCR_seekResourceByIndex(mapIndex,'M');
|
||||
LCR_mapLoadFromStr(LCR_gameGetNextResourceStrChar);
|
||||
|
||||
mapName[0] = 0;
|
||||
|
||||
for (int i = 0; i < LCR_MAP_NAME_MAX_LEN; ++i)
|
||||
{
|
||||
char c = LCR_gameGetNextResourceFileChar();
|
||||
|
||||
if (c == LCR_RESOURCE_FILE_SEPARATOR2 ||
|
||||
c == LCR_RESOURCE_FILE_SEPARATOR || c == 0)
|
||||
break;
|
||||
|
||||
mapName[i] = c;
|
||||
mapName[i + 1] = 0;
|
||||
}
|
||||
|
||||
LCR_mapLoadFromStr(LCR_gameGetNextResourceStrChar,mapName);
|
||||
LCR_gameSetState(LCR_GAME_STATE_LOADING_MAP);
|
||||
}
|
||||
|
||||
|
@ -821,6 +835,11 @@ void LCR_gameHandleInput(void)
|
|||
LCR_game.menu.selectedTab == 1 ? 'M' : 'R');
|
||||
}
|
||||
|
||||
void _LCR_gameResourceCharWrite(char c)
|
||||
{
|
||||
printf("%c",c);
|
||||
}
|
||||
|
||||
uint8_t LCR_gameStep(uint32_t time)
|
||||
{
|
||||
uint32_t sleep = 0;
|
||||
|
@ -871,6 +890,8 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
|
||||
{
|
||||
LCR_LOG1("finished");
|
||||
LCR_replayOutputStr(_LCR_gameResourceCharWrite);
|
||||
|
||||
LCR_audioPlaySound(LCR_SOUND_CLICK);
|
||||
LCR_gameSetState(LCR_GAME_STATE_RUN_FINISHED);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue