Rework CPs
This commit is contained in:
parent
3eeb4d7fc2
commit
367112dbd9
4 changed files with 79 additions and 39 deletions
51
racing.h
51
racing.h
|
@ -559,6 +559,7 @@ void _LCR_racingUpdateCarPosRot(void)
|
|||
void LCR_racingRestart(void)
|
||||
{
|
||||
LCR_LOG0("restarting race");
|
||||
LCR_mapReset();
|
||||
|
||||
LCR_racing.tick = 0;
|
||||
LCR_racing.fanForce = 0;
|
||||
|
@ -690,6 +691,22 @@ void LCR_racingGetCarTransform(LCR_GameUnit position[3],
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the current block coordinates of the car, without interpolation etc.,
|
||||
intended for checking accurately whether CP has been taken etc.
|
||||
*/
|
||||
void LCR_racingGetCarBlockCoords(int coords[3])
|
||||
{
|
||||
coords[0] = (LCR_racing.carPositions[0].x +
|
||||
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT;
|
||||
|
||||
coords[1] = (LCR_racing.carPositions[0].y +
|
||||
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 4) / (LCR_GAME_UNIT / 2);
|
||||
|
||||
coords[2] = (LCR_racing.carPositions[0].z +
|
||||
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT;
|
||||
}
|
||||
|
||||
void _LCR_drawPhysicsDebugPixel(uint16_t x, uint16_t y, uint8_t color)
|
||||
{
|
||||
if (x > 1 && x < LCR_EFFECTIVE_RESOLUTION_X - 2 &&
|
||||
|
@ -1006,13 +1023,45 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
{
|
||||
TPE_bodyAccelerate(&(LCR_racing.carBody),TPE_vec3(0,LCR_racing.fanForce,0));
|
||||
|
||||
|
||||
LCR_racing.fanForce -= LCR_GRAVITY / LCR_FAN_FORCE_DECREASE;
|
||||
|
||||
if (LCR_racing.fanForce < 0)
|
||||
LCR_racing.fanForce = 0;
|
||||
}
|
||||
|
||||
int carBlock[3];
|
||||
|
||||
LCR_racingGetCarBlockCoords(carBlock);
|
||||
|
||||
carBlock[0] = LCR_mapGetBlockAt(carBlock[0],carBlock[1],carBlock[2]);
|
||||
|
||||
if (carBlock[0] >= 0)
|
||||
{
|
||||
if (LCR_currentMap.blocks[carBlock[0] * LCR_BLOCK_SIZE] ==
|
||||
LCR_BLOCK_CHECKPOINT_0)
|
||||
{
|
||||
LCR_currentMap.blocks[carBlock[0] * LCR_BLOCK_SIZE] =
|
||||
LCR_BLOCK_CHECKPOINT_1;
|
||||
|
||||
result |= LCR_RACING_EVENT_CP_TAKEN;
|
||||
}
|
||||
else if (LCR_currentMap.blocks[carBlock[0] * LCR_BLOCK_SIZE] ==
|
||||
LCR_BLOCK_FINISH)
|
||||
{
|
||||
int valid = 1;
|
||||
|
||||
for (int i = 0; i < LCR_currentMap.blockCount; ++i)
|
||||
if (LCR_currentMap.blocks[i * LCR_BLOCK_SIZE] == LCR_BLOCK_CHECKPOINT_0)
|
||||
{
|
||||
valid = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
result |= LCR_RACING_EVENT_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
LCR_LOG2("gonna step physics engine");
|
||||
TPE_worldStep(&(LCR_racing.physicsWorld));
|
||||
LCR_LOG2("stepping physics engine done");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue