diff --git a/TODO.txt b/TODO.txt index 93b60f5..dca7ca3 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,8 @@ =========== GENERAL ============== +- rework the code for special blocks, we have to literally remember the last + block, not the pointer, now it won't work e.g. if wanting to repeat an + empty block - allow stopping car rotation in air like in Trackmania - maybe allow some more air control, like slowing down with brakes, like in TM - sound engine: probably all SFX will be procedurally generated, ok? diff --git a/assets.h b/assets.h index cca55f2..17e9fe7 100644 --- a/assets.h +++ b/assets.h @@ -40,7 +40,8 @@ static const char *LCR_maps[] = "#=f0s0 #f11d0" "#=c0p0 #f11d0" - "#=C0s1 #fd190" // big dirt +"#>C0s0 #fd190" // big dirt +// "#=C0s1 #fd190" // big dirt "#=M0s2 #fd190" // big grass "#=W0s3 #fd190" // big ice diff --git a/map.h b/map.h index ca62e97..f9389fe 100644 --- a/map.h +++ b/map.h @@ -637,6 +637,11 @@ void _LCR_addBlockShapeByte(uint8_t *bytes, uint8_t *byteCount, *byteCount += 1; } +uint8_t LCR_mapBlockIsAccelerator(uint8_t block) +{ + return block == LCR_BLOCK_FULL_ACCEL; +} + /** Macro that transforms coordinates according to block transformation. */ @@ -825,27 +830,27 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform, break; } -case LCR_BLOCK_CORNER_CONVEX: -case LCR_BLOCK_CORNER_CONCAVE: -{ - uint8_t - mx = blockType == LCR_BLOCK_CORNER_CONVEX ? 4 : 2, - mz = blockType == LCR_BLOCK_CORNER_CONVEX ? 2 : 4; + case LCR_BLOCK_CORNER_CONVEX: + case LCR_BLOCK_CORNER_CONCAVE: + { + uint8_t + mx = blockType == LCR_BLOCK_CORNER_CONVEX ? 4 : 2, + mz = blockType == LCR_BLOCK_CORNER_CONVEX ? 2 : 4; - ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left - ADD(0,0,0) ADD(0,4,0) ADD(0,4,6) // left - ADD(6,0,6) ADD(0,0,6) ADD(0,4,6) // back - ADD(0,4,6) ADD(6,4,6) ADD(6,0,6) // back - ADD(0,0,0) ADD(mx,4,mz) ADD(0,4,0) // right - ADD(mx,0,mz) ADD(mx,4,mz) ADD(0,0,0) - ADD(6,4,6) ADD(mx,4,mz) ADD(6,0,6) - ADD(6,0,6) ADD(mx,4,mz) ADD(mx,0,mz) - ADD(0,4,0) ADD(mx,4,mz) ADD(0,4,6) // top - ADD(0,4,6) ADD(mx,4,mz) ADD(6,4,6) - ADD(0,0,0) ADD(0,0,6) ADD(mx,0,mz) // bottom - ADD(0,0,6) ADD(6,0,6) ADD(mx,0,mz) - break; -} + ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left + ADD(0,0,0) ADD(0,4,0) ADD(0,4,6) // left + ADD(6,0,6) ADD(0,0,6) ADD(0,4,6) // back + ADD(0,4,6) ADD(6,4,6) ADD(6,0,6) // back + ADD(0,0,0) ADD(mx,4,mz) ADD(0,4,0) // right + ADD(mx,0,mz) ADD(mx,4,mz) ADD(0,0,0) + ADD(6,4,6) ADD(mx,4,mz) ADD(6,0,6) + ADD(6,0,6) ADD(mx,4,mz) ADD(mx,0,mz) + ADD(0,4,0) ADD(mx,4,mz) ADD(0,4,6) // top + ADD(0,4,6) ADD(mx,4,mz) ADD(6,4,6) + ADD(0,0,0) ADD(0,0,6) ADD(mx,0,mz) // bottom + ADD(0,0,6) ADD(6,0,6) ADD(mx,0,mz) + break; + } case LCR_BLOCK_BUMP: ADD(3,0,0) ADD(6,0,3) ADD(3,1,3) // top diff --git a/racing.h b/racing.h index 5126612..ef8bafe 100644 --- a/racing.h +++ b/racing.h @@ -689,13 +689,16 @@ TPE_Unit _LCR_applyMaterialFactor(TPE_Unit value, uint8_t mat) } void _LCR_racingWheelAccelerate(unsigned int wheel, TPE_Vec3 dir, - uint8_t material) + uint8_t material, uint8_t accelerator) { TPE_Unit acc = _LCR_applyMaterialFactor(LCR_CAR_ACCELERATION,material); acc = acc / (1 + (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_AIR_FRICTION)); + if (accelerator) + acc *= 2; // TODO: constant? + LCR_racing.carBody.joints[wheel].velocity[0] += (dir.x * acc) / TPE_F; LCR_racing.carBody.joints[wheel].velocity[1] += @@ -727,23 +730,10 @@ uint32_t LCR_racingStep(unsigned int input) { LCR_LOG2("racing step start"); -/* -for (int i = 0; i < LCR_CAR_JOINTS; ++i) - printf(" %d: %d %d %d, %d %d %d\n", - i,LCR_racing.carBody.joints[i].position.x, - LCR_racing.carBody.joints[i].position.y, - LCR_racing.carBody.joints[i].position.z, - LCR_racing.carBody.joints[i].velocity[0], - LCR_racing.carBody.joints[i].velocity[1], - LCR_racing.carBody.joints[i].velocity[0]); - -printf("------\n"); -*/ - - uint32_t result = 0; TPE_Vec3 carForw, carRight, carUp, carVel; uint8_t groundMat = LCR_BLOCK_MATERIAL_CONCRETE; // material under wheels + uint8_t onAccel = 0; // standing on accelerator? int groundBlockIndex = -1; carForw = TPE_vec3Normalized(TPE_vec3Plus( @@ -795,13 +785,20 @@ printf("------\n"); } if (groundBlockIndex != -1) + { + onAccel = LCR_mapBlockIsAccelerator( + LCR_currentMap.blocks[groundBlockIndex * LCR_BLOCK_SIZE]); groundMat = LCR_mapBlockGetMaterial( LCR_currentMap.blocks + groundBlockIndex * LCR_BLOCK_SIZE); + } } LCR_racing.carBody.friction = _LCR_applyMaterialFactor(LCR_CAR_FORWARD_FRICTION,groundMat); + if (onAccel) + input |= LCR_RACING_INPUT_FORW; // accelerator enforces this + if(!(input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))) LCR_racing.carBody.friction *= LCR_CAR_STAND_FRICTION_MULTIPLIER; else if ( @@ -863,13 +860,13 @@ printf("------\n"); { if (input & LCR_RACING_INPUT_FORW) { - _LCR_racingWheelAccelerate(0,carForw,groundMat); - _LCR_racingWheelAccelerate(1,carForw,groundMat); + _LCR_racingWheelAccelerate(0,carForw,groundMat,onAccel); + _LCR_racingWheelAccelerate(1,carForw,groundMat,onAccel); } else if (input & LCR_RACING_INPUT_BACK) { - _LCR_racingWheelAccelerate(0,TPE_vec3TimesPlain(carForw,-1),groundMat); - _LCR_racingWheelAccelerate(1,TPE_vec3TimesPlain(carForw,-1),groundMat); + _LCR_racingWheelAccelerate(0,TPE_vec3TimesPlain(carForw,-1),groundMat,onAccel); + _LCR_racingWheelAccelerate(1,TPE_vec3TimesPlain(carForw,-1),groundMat,onAccel); } }