288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
const float friction =
water ? 20.0f : (pl.onFloor || floating ? 6.0f : 30.0f);
const float fpsfric = friction / curtime * 20.0f;
// slowly apply friction and direction to
// velocity, gives a smooth movement
vmul(pl.velocity, fpsfric - 1);
vadd(pl.velocity, d);
vdiv(pl.velocity, fpsfric);
d = pl.velocity;
vmul(d, speed); // d is now frametime based velocity vector
pl.blocked = false;
pl.moving = true;
if (floating) {
// just apply velocity
vadd(pl.origin, d);
if (pl.jumpNext) {
pl.jumpNext = false;
pl.velocity =
OFMakeVector3D(pl.velocity.x, pl.velocity.y, 2);
}
} else {
// apply velocity with collision
|
|
|
|
|
|
>
|
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
const float friction =
water ? 20.0f : (pl.onFloor || floating ? 6.0f : 30.0f);
const float fpsfric = friction / curtime * 20.0f;
// slowly apply friction and direction to
// velocity, gives a smooth movement
OFVector3D velocity = OFMultiplyVector3D(pl.velocity, fpsfric - 1);
velocity = OFAddVectors3D(velocity, d);
velocity = OFMultiplyVector3D(velocity, 1.0f / fpsfric);
pl.velocity = velocity;
// d is now frametime based velocity vector
d = OFMultiplyVector3D(velocity, speed);
pl.blocked = false;
pl.moving = true;
if (floating) {
// just apply velocity
pl.origin = OFAddVectors3D(pl.origin, d);
if (pl.jumpNext) {
pl.jumpNext = false;
pl.velocity =
OFMakeVector3D(pl.velocity.x, pl.velocity.y, 2);
}
} else {
// apply velocity with collision
|