Rework CPs
This commit is contained in:
parent
3eeb4d7fc2
commit
367112dbd9
4 changed files with 79 additions and 39 deletions
53
game.h
53
game.h
|
@ -146,7 +146,6 @@ struct
|
|||
uint32_t nextRacingTickTime;
|
||||
uint8_t controlMode;
|
||||
uint8_t debugDraw;
|
||||
uint8_t checkpointsTaken;
|
||||
uint32_t runTime;
|
||||
|
||||
uint8_t musicVolume;
|
||||
|
@ -218,7 +217,6 @@ void LCR_gameResetRun(void)
|
|||
LCR_GameUnit carTransform[6];
|
||||
|
||||
LCR_LOG0("resetting run");
|
||||
LCR_game.checkpointsTaken = 0;
|
||||
LCR_mapReset();
|
||||
LCR_racingRestart();
|
||||
LCR_rendererUnmarkCPs();
|
||||
|
@ -262,12 +260,12 @@ void LCR_gameEnd(void)
|
|||
|
||||
uint8_t LCR_gameStep(uint32_t time)
|
||||
{
|
||||
LCR_GameUnit carTransform[6];
|
||||
|
||||
LCR_LOG2("game step start");
|
||||
|
||||
LCR_game.time = time;
|
||||
|
||||
LCR_GameUnit carTransform[6];
|
||||
|
||||
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
|
||||
LCR_keyStates[i] = LCR_keyPressed(i) ?
|
||||
(LCR_keyStates[i] < 255 ? LCR_keyStates[i] + 1 : 255) : 0;
|
||||
|
@ -292,40 +290,19 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
(LCR_keyStates[LCR_KEY_DOWN] ? LCR_RACING_INPUT_BACK : 0) |
|
||||
(LCR_keyStates[LCR_KEY_LEFT] ? LCR_RACING_INPUT_LEFT : 0);
|
||||
|
||||
LCR_racingStep(input);
|
||||
uint32_t events = LCR_racingStep(input);
|
||||
|
||||
LCR_racingGetCarTransform(carTransform,carTransform + 3,0);
|
||||
|
||||
carTransform[0] = (carTransform[0] + (LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS)
|
||||
/ 2) / LCR_GAME_UNIT;
|
||||
carTransform[1] = (carTransform[1] + (LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS)
|
||||
/ 4) / (LCR_GAME_UNIT / 2);
|
||||
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]);
|
||||
|
||||
if (blockIndex >= 0)
|
||||
if (events & LCR_RACING_EVENT_CP_TAKEN)
|
||||
{
|
||||
if (LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] ==
|
||||
LCR_BLOCK_CHECKPOINT_0)
|
||||
{
|
||||
LCR_LOG1("CP taken");
|
||||
int carBlock[3];
|
||||
|
||||
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");
|
||||
|
||||
|
||||
}
|
||||
LCR_racingGetCarBlockCoords(carBlock);
|
||||
LCR_LOG1("CP taken");
|
||||
LCR_rendererMarkTakenCP(carBlock[0],carBlock[1],carBlock[2]);
|
||||
}
|
||||
else if (events & LCR_RACING_EVENT_FINISHED)
|
||||
{
|
||||
LCR_LOG1("finished");
|
||||
}
|
||||
|
||||
LCR_game.runTime++;
|
||||
|
@ -338,9 +315,9 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
{
|
||||
LCR_LOG2("gonna render next frame");
|
||||
|
||||
LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
|
||||
((LCR_game.nextRacingTickTime - time) * LCR_GAME_UNIT) /
|
||||
LCR_RACING_TICK_MS;
|
||||
LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
|
||||
((LCR_game.nextRacingTickTime - time) * LCR_GAME_UNIT)
|
||||
/ LCR_RACING_TICK_MS;
|
||||
|
||||
LCR_racingGetCarTransform(carTransform,carTransform + 3,
|
||||
physicsInterpolationParam);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue