Fix car params
This commit is contained in:
parent
d6380a0e45
commit
be322fb37a
3 changed files with 61 additions and 34 deletions
21
assets.h
21
assets.h
|
@ -19,13 +19,20 @@
|
|||
static const char *LCR_maps[] =
|
||||
{
|
||||
"LM;;;0;#*s1s0"
|
||||
"#=s0s0 #fd190"
|
||||
"#=C0s1 #fd190"
|
||||
"#=M0s2 #fd190"
|
||||
"#=W0s3 #fd190"
|
||||
"#(s0r0"
|
||||
"#~t1t2 #~u1t2 #~t1u2"
|
||||
"#^t0r0"
|
||||
|
||||
"#=s0s0 #fd190" // big concrete
|
||||
"#=s0B0 #fd910" // concrete wall
|
||||
"#^s1A0 #f7110" // ramps before wall
|
||||
|
||||
"#;p0w0L #f5130" // bugs
|
||||
|
||||
"#=C0s1 #fd190" // big dirt
|
||||
"#=M0s2 #fd190" // big grass
|
||||
"#=W0s3 #fd190" // big ice
|
||||
|
||||
"#(s0r0" // hill
|
||||
"#~t1t2 #~u1t2 #~t1u2" // bumps
|
||||
"#^t0r0 #f7110 " // ramps
|
||||
};
|
||||
|
||||
#define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image
|
||||
|
|
2
game.h
2
game.h
|
@ -247,6 +247,8 @@ if ((LCR_racing.tick % 32) == 0)
|
|||
LCR_game.controlMode = LCR_game.controlMode == LCR_CONTROL_MODE_FREECAM ?
|
||||
LCR_CONTROL_MODE_DRIVE : LCR_CONTROL_MODE_FREECAM;
|
||||
else if (LCR_keyStates[LCR_KEY_B] == 30)
|
||||
LCR_racingRestart();
|
||||
else if (LCR_keyStates[LCR_KEY_B] == 60)
|
||||
LCR_game.debugDraw = !LCR_game.debugDraw;
|
||||
|
||||
while (time >= LCR_game.nextRacingTickTime)
|
||||
|
|
72
racing.h
72
racing.h
|
@ -19,7 +19,7 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
|
|||
#define LCR_RACING_EVENT_CRASH_SMALL 0x0004
|
||||
#define LCR_RACING_EVENT_CRASH_BIG 0x0008
|
||||
|
||||
#define LCR_PHYSICS_UNIT 2048 ///< length of map square for physics engine
|
||||
#define LCR_PHYSICS_UNIT 4096 ///< length of map square for physics engine
|
||||
|
||||
#define TPE_RESHAPE_TENSION_LIMIT 10
|
||||
#define TPE_RESHAPE_ITERATIONS 5
|
||||
|
@ -31,12 +31,16 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
|
|||
|
||||
#define LCR_GRAVITY (LCR_PHYSICS_UNIT / 160)
|
||||
#define LCR_CAR_FORWARD_FRICTION (TPE_F / 180)
|
||||
#define LCR_CAR_AIR_FRICTION ((LCR_GAME_UNIT * 3) / 4)
|
||||
//#define LCR_CAR_AIR_FRICTION ((LCR_GAME_UNIT * 3) / 4)
|
||||
#define LCR_CAR_AIR_FRICTION 32
|
||||
|
||||
#define LCR_CAR_STAND_FRICTION_MULTIPLIER 16
|
||||
#define LCR_CAR_STEER_FRICTION (TPE_F)
|
||||
#define LCR_CAR_ELASTICITY (TPE_F / 50)
|
||||
#define LCR_CAR_ACCELERATION (LCR_PHYSICS_UNIT / 90)
|
||||
#define LCR_CAR_STEER_SPEED (LCR_GAME_UNIT / 32)
|
||||
#define LCR_CAR_ELASTICITY (TPE_F / 150)
|
||||
//#define LCR_CAR_ACCELERATION (LCR_PHYSICS_UNIT / 90)
|
||||
#define LCR_CAR_ACCELERATION (LCR_PHYSICS_UNIT / 20)
|
||||
|
||||
#define LCR_CAR_STEER_SPEED (LCR_GAME_UNIT / 16)
|
||||
#define LCR_CAR_STEER_MAX ((7 * LCR_GAME_UNIT) / 24)
|
||||
|
||||
// TODO
|
||||
|
@ -429,7 +433,30 @@ void LCR_racingRestart(void)
|
|||
|
||||
LCR_racing.carRotations[0] = TPE_vec3(0,0,0);
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
|
||||
|
||||
// make the car body:
|
||||
TPE_makeCenterRectFull(LCR_racing.carJoints,
|
||||
LCR_racing.carConnections,
|
||||
LCR_PHYSICS_UNIT / 2,
|
||||
(LCR_PHYSICS_UNIT * 3) / 4,
|
||||
LCR_PHYSICS_UNIT / 8);
|
||||
|
||||
LCR_racing.carJoints[4].position.y += LCR_PHYSICS_UNIT / 6;
|
||||
LCR_racing.carJoints[4].sizeDivided *= 3;
|
||||
LCR_racing.carJoints[4].sizeDivided /= 2;
|
||||
|
||||
TPE_bodyInit(&(LCR_racing.carBody),LCR_racing.carJoints,LCR_CAR_JOINTS,
|
||||
LCR_racing.carConnections,LCR_CAR_CONNECTIONS,TPE_F);
|
||||
|
||||
LCR_racing.carBody.friction = LCR_CAR_FORWARD_FRICTION;
|
||||
LCR_racing.carBody.elasticity = LCR_CAR_ELASTICITY;
|
||||
LCR_racing.carBody.flags |= TPE_BODY_FLAG_ALWAYS_ACTIVE;
|
||||
|
||||
/* We disable bounding sphere checks because that would lead to calling env.
|
||||
function with large min. distance which would lead to slow iteration over
|
||||
all map blocks. */
|
||||
LCR_racing.carBody.flags |= TPE_BODY_FLAG_NO_BSPHERE;
|
||||
|
||||
TPE_bodyMoveTo(&(LCR_racing.carBody),
|
||||
TPE_vec3(
|
||||
(((TPE_Unit) LCR_currentMap.startPos[0]) - LCR_MAP_SIZE_BLOCKS / 2)
|
||||
|
@ -463,33 +490,16 @@ void LCR_racingInit(void)
|
|||
{
|
||||
LCR_LOG0("initializing racing engine");
|
||||
|
||||
// make the car body:
|
||||
TPE_makeCenterRectFull(LCR_racing.carJoints,
|
||||
LCR_racing.carConnections,
|
||||
LCR_PHYSICS_UNIT / 2,
|
||||
(LCR_PHYSICS_UNIT * 3) / 4,
|
||||
LCR_PHYSICS_UNIT / 8);
|
||||
|
||||
LCR_racing.carJoints[4].position.y += LCR_PHYSICS_UNIT / 6;
|
||||
LCR_racing.carJoints[4].sizeDivided *= 3;
|
||||
LCR_racing.carJoints[4].sizeDivided /= 2;
|
||||
|
||||
TPE_bodyInit(&(LCR_racing.carBody),LCR_racing.carJoints,LCR_CAR_JOINTS,
|
||||
LCR_racing.carConnections,LCR_CAR_CONNECTIONS,TPE_F);
|
||||
|
||||
|
||||
|
||||
TPE_worldInit(&(LCR_racing.physicsWorld),
|
||||
&(LCR_racing.carBody),1,_LCR_racingEnvironmentFunction);
|
||||
|
||||
LCR_racing.physicsWorld.collisionCallback = _LCR_racingCollisionHandler;
|
||||
|
||||
LCR_racing.carBody.friction = LCR_CAR_FORWARD_FRICTION;
|
||||
LCR_racing.carBody.elasticity = LCR_CAR_ELASTICITY;
|
||||
LCR_racing.carBody.flags |= TPE_BODY_FLAG_ALWAYS_ACTIVE;
|
||||
|
||||
/* We disable bounding sphere checks because that would lead to calling env.
|
||||
function with large min. distance which would lead to slow iteration over
|
||||
all map blocks. */
|
||||
LCR_racing.carBody.flags |= TPE_BODY_FLAG_NO_BSPHERE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -571,12 +581,18 @@ void _LCR_racingWheelAccelerate(unsigned int wheel, TPE_Vec3 dir,
|
|||
LCR_CAR_ACCELERATION_GRASS :
|
||||
LCR_CAR_ACCELERATION);
|
||||
|
||||
/*
|
||||
acc -=
|
||||
(acc * LCR_racing.carSpeed) / LCR_CAR_AIR_FRICTION;
|
||||
*/
|
||||
|
||||
acc =
|
||||
acc / (1 + (LCR_racing.carSpeed / LCR_CAR_AIR_FRICTION));
|
||||
|
||||
/*
|
||||
if (acc < 0)
|
||||
acc = 0;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
LCR_racing.carBody.joints[wheel].velocity[0] +=
|
||||
|
@ -754,8 +770,10 @@ if (!(input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)))
|
|||
|
||||
/* friction is in the direction if the axis and its magnitude is
|
||||
determined by the dot product (angle) of the axis and velocity */
|
||||
|
||||
|
||||
TPE_Vec3 fric = TPE_vec3Times(ja,(TPE_vec3Dot(ja,jv) *
|
||||
(groundMat == LCR_BLOCK_MATERIAL_CONCRETE ?
|
||||
(/*groundMat == LCR_BLOCK_MATERIAL_CONCRETE*/ 1 ?
|
||||
LCR_CAR_STEER_FRICTION :
|
||||
(groundMat == LCR_BLOCK_MATERIAL_DIRT ?
|
||||
LCR_CAR_STEER_FRICTION_DIRT :
|
||||
|
|
Loading…
Reference in a new issue