Count CPs
This commit is contained in:
parent
f0c2977002
commit
a388a915f9
4 changed files with 69 additions and 8 deletions
40
game.h
40
game.h
|
@ -123,6 +123,7 @@ struct
|
|||
uint32_t nextRacingTickTime;
|
||||
uint8_t controlMode;
|
||||
uint8_t debugDraw;
|
||||
uint8_t checkpointsTaken;
|
||||
} LCR_game;
|
||||
|
||||
void LCR_drawPixelXYUnsafe(unsigned int x, unsigned int y,
|
||||
|
@ -162,6 +163,14 @@ static inline void LCR_drawPixelXYSafe(unsigned int x, unsigned int y,
|
|||
LCR_drawPixelXYUnsafe(x,y,color);
|
||||
}
|
||||
|
||||
void LCR_gameResetRun(void)
|
||||
{
|
||||
LCR_LOG0("resetting run");
|
||||
LCR_game.checkpointsTaken = 0;
|
||||
LCR_mapReset();
|
||||
LCR_rendererUnmarkCPs();
|
||||
}
|
||||
|
||||
void LCR_gameInit(void)
|
||||
{
|
||||
LCR_LOG0("initializing");
|
||||
|
@ -178,6 +187,8 @@ void LCR_gameInit(void)
|
|||
|
||||
LCR_game.controlMode = LCR_CONTROL_MODE_FREECAM;
|
||||
LCR_game.debugDraw = 0;
|
||||
|
||||
LCR_gameResetRun();
|
||||
}
|
||||
|
||||
void LCR_gameEnd(void)
|
||||
|
@ -234,15 +245,30 @@ if ((LCR_racing.tick % 32) == 0)
|
|||
carTransform[2] = (carTransform[2] + (LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS)
|
||||
/ 2) / LCR_GAME_UNIT;
|
||||
|
||||
int blockIndex = LCR_mapGetBlockAt(carTransform[0],carTransform[1],carTransform[2]);
|
||||
int blockIndex =
|
||||
LCR_mapGetBlockAt(carTransform[0],carTransform[1],carTransform[2]);
|
||||
|
||||
if (blockIndex >= 0 && LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] ==
|
||||
LCR_BLOCK_CHECKPOINT_0)
|
||||
if (blockIndex >= 0)
|
||||
{
|
||||
LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] =
|
||||
LCR_BLOCK_CHECKPOINT_1;
|
||||
LCR_rendererMarkTakenCP(
|
||||
carTransform[0],carTransform[1],carTransform[2]);
|
||||
if (LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] ==
|
||||
LCR_BLOCK_CHECKPOINT_0)
|
||||
{
|
||||
LCR_LOG1("CP taken");
|
||||
|
||||
LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] =
|
||||
LCR_BLOCK_CHECKPOINT_1;
|
||||
LCR_rendererMarkTakenCP(
|
||||
carTransform[0],carTransform[1],carTransform[2]);
|
||||
LCR_game.checkpointsTaken++;
|
||||
}
|
||||
else if (LCR_game.checkpointsTaken == LCR_currentMap.checkpointCount &&
|
||||
LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] == LCR_BLOCK_FINISH)
|
||||
{
|
||||
LCR_LOG1("finished");
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LCR_game.nextRacingTickTime += LCR_RACING_TICK_MS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue