Take checkpoints

This commit is contained in:
Miloslav Ciz 2024-11-21 21:33:36 +01:00
parent f248981676
commit f0c2977002
3 changed files with 25 additions and 4 deletions

View file

@ -60,8 +60,7 @@ LCR_MAP_BLOCK(LCR_BLOCK_RAMP_STEEP,4,4,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_T
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_PLAT,4,5,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_FLIP_V | LCR_BLOCK_TRANSFORM_ROT_180),
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_PLAT,3,5,6,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_FLIP_V | LCR_BLOCK_TRANSFORM_ROT_180),
LCR_MAP_BLOCK(LCR_BLOCK_CHECKPOINT_0,3,2,4,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FINISH,3,2,2,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_CHECKPOINT_0,3,1,4,LCR_BLOCK_MATERIAL_CONCRETE,0),
/*
LCR_MAP_BLOCK(LCR_BLOCK_FULL,2,1,9,LCR_BLOCK_MATERIAL_CONCRETE,0),

25
game.h
View file

@ -11,6 +11,7 @@
- LCR_GameUnit: data type, abstract unit of the game (racing module). One map
square is LCR_GAME_UNITs long, a full angle is also LCR_GAME_UNITs.
- LCR_GAME_UNIT: Size of one game square and full angle in LCR_GameUnits.
Square height is only half of this.
- S3L_Unit: data type, small3dlib's unit. May change with renderer change.
- S3L_F: small3dlib's value representing 1.0.
- LCR_RENDERER_UNIT: for the renderer one map square is this many S3L_Units.
@ -188,6 +189,8 @@ uint8_t LCR_gameStep(uint32_t time)
{
LCR_LOG2("game step start");
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;
@ -221,6 +224,27 @@ if ((LCR_racing.tick % 32) == 0)
(LCR_keyStates[LCR_KEY_LEFT] ? LCR_RACING_INPUT_LEFT : 0);
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 && LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] ==
LCR_BLOCK_CHECKPOINT_0)
{
LCR_currentMap.blocks[blockIndex * LCR_BLOCK_SIZE] =
LCR_BLOCK_CHECKPOINT_1;
LCR_rendererMarkTakenCP(
carTransform[0],carTransform[1],carTransform[2]);
}
LCR_game.nextRacingTickTime += LCR_RACING_TICK_MS;
}
@ -234,7 +258,6 @@ LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
((LCR_game.nextRacingTickTime - time) * LCR_GAME_UNIT) /
LCR_RACING_TICK_MS;
LCR_GameUnit carTransform[6];
LCR_racingGetCarTransform(carTransform,carTransform + 3,
physicsInterpolationParam);

View file

@ -580,7 +580,6 @@ int _LCR_racingCarShapeOK(void)
*/
uint32_t LCR_racingStep(unsigned int input)
{
printf("---------\n");
LCR_LOG2("racing step start");
uint32_t result = 0;