Add map target time

This commit is contained in:
Miloslav Ciz 2025-01-15 21:29:38 +01:00
parent ea57ecd470
commit 9d2c6108b1
3 changed files with 60 additions and 35 deletions

View file

@ -42,7 +42,7 @@ static const char *LCR_texts[] =
static const char *LCR_internalResourceFile = static const char *LCR_internalResourceFile =
"Mtestmap;" "Mtestmap;"
"1 :*H1k0" "52123 1 :*H1k0"
":=s0s0 :fd190" // big concrete ":=s0s0 :fd190" // big concrete
@ -84,16 +84,16 @@ static const char *LCR_internalResourceFile =
":-k5k0 :f5120" ":-k5k0 :f5120"
" map end " " map end "
"#Mmap2;1 :*H1k0J :,s0s0 :fd190 " "#Mmap2;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Rtestrepl;aaa#Rrepl2;" "#Rtestrepl;aaa#Rrepl2;"
"#Mmap3;1 :*H1k0J :,s0s0 :fd190 " "#Mmap3;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap4;1 :*H1k0J :,s0s0 :fd190 " "#Mmap4;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap5;1 :*H1k0J :,s0s0 :fd190 " "#Mmap5;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap6;1 :*H1k0J :,s0s0 :fd190 " "#Mmap6;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap7;1 :*H1k0J :,s0s0 :fd190 " "#Mmap7;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap8;1 :*H1k0J :,s0s0 :fd190 " "#Mmap8;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap9;1 :*H1k0J :,s0s0 :fd190 " "#Mmap9;4321 1 :*H1k0J :,s0s0 :fd190 "
"#Mmap10;1 :*H1k0J :,s0s0 :fd190 " "#Mmap10;4321 1 :*H1k0J :,s0s0 :fd190 "
; ;
#define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image #define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image

53
game.h
View file

@ -560,6 +560,31 @@ void LCR_gameEnd(void)
LCR_LOG0("ending"); LCR_LOG0("ending");
} }
void LCR_gameTimeToStr(uint32_t timeMS, char *str)
{
str[9] = 0;
str[6] = '0' + timeMS % 10; // milliseconds
timeMS /= 10;
str[7] = '0' + timeMS % 10;
timeMS /= 10;
str[8] = '0' + timeMS % 10;
timeMS /= 10;
str[3] = '0' + (timeMS % 60) / 10; // seconds
str[4] = '0' + timeMS % 10;
str[5] = '\'';
timeMS = (timeMS / 60) % 100; // minutes
str[0] = '0' + timeMS / 10;
str[1] = '0' + timeMS % 10;
str[2] = '\'';
}
void LCR_gameDraw3DView(void) void LCR_gameDraw3DView(void)
{ {
LCR_GameUnit carTransform[6]; LCR_GameUnit carTransform[6];
@ -626,29 +651,15 @@ void LCR_gameDraw3DView(void)
LCR_EFFECTIVE_RESOLUTION_Y - LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 20,0,2); LCR_rendererComputeTextHeight(2) - 20,0,2);
val = LCR_game.runTimeMS; LCR_gameTimeToStr(LCR_game.runTimeMS,str);
str[9] = 0;
str[6] = '0' + val % 10; // milliseconds
val /= 10;
str[7] = '0' + val % 10;
val /= 10;
str[8] = '0' + val % 10;
val /= 10;
str[3] = '0' + (val % 60) / 10; // seconds
str[4] = '0' + val % 10;
str[5] = '\'';
val = (val / 60) % 100; // minutes
str[0] = '0' + val / 10;
str[1] = '0' + val % 10;
str[2] = '\'';
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y - LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 20,0,2); LCR_rendererComputeTextHeight(2) - 45,0,2);
LCR_gameTimeToStr(LCR_currentMap.targetTime,str);
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 20,0x4208,2);
break; break;
} }

22
map.h
View file

@ -13,10 +13,12 @@
The TEXT format serves for editing maps in human readable format, it more or The TEXT format serves for editing maps in human readable format, it more or
less corresponds to the binary storage format (below) with some exceptions. less corresponds to the binary storage format (below) with some exceptions.
It has the following structure: It has the following structure:
- Number specifying environment (0, 1, 2, ...) - Target time as a decimal number of milliseconds.
- A series of block strings. Blocks may be separated by characters that - Non-decimal character.
aren't ':' (comments may be added this way). Block format - Number of environment (0, 1, 2, ...)
is following: - A series of block strings. Blocks may be preceded/followed by characters
that aren't ':' (comments may be added this way). Block format is
following:
:BXYZMT :BXYZMT
@ -153,6 +155,7 @@ struct
uint8_t checkpointCount; uint8_t checkpointCount;
uint32_t hash; ///< Hash of the processed binary map. uint32_t hash; ///< Hash of the processed binary map.
uint32_t targetTime;
char name[LCR_MAP_NAME_MAX_LEN + 1]; char name[LCR_MAP_NAME_MAX_LEN + 1];
} LCR_currentMap; } LCR_currentMap;
@ -398,11 +401,22 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name)
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
LCR_currentMap.startPos[i] = 0; LCR_currentMap.startPos[i] = 0;
LCR_currentMap.targetTime = 0;
LCR_currentMap.checkpointCount = 0; LCR_currentMap.checkpointCount = 0;
LCR_currentMap.blockCount = 0; LCR_currentMap.blockCount = 0;
LCR_currentMap.environment = 0; LCR_currentMap.environment = 0;
LCR_currentMap.hash = 0; LCR_currentMap.hash = 0;
while (1) // read target time
{
c = getNextCharFunc();
if (c >= '0' && c <= '9')
LCR_currentMap.targetTime = LCR_currentMap.targetTime * 10 + c - '0';
else
break;
}
c = getNextCharFunc(); c = getNextCharFunc();
if (c < '0' || c > '3') if (c < '0' || c > '3')