Commit fe5db301 authored by NY00123's avatar NY00123
Browse files

sw/src/player.cpp:DoPlayerTurn: Increase turning precision

with q16 angle. This uses the new NORM_Q16ANGLE macro.
parent 25bce29d
......@@ -381,6 +381,7 @@ extern char MessageOutputString[256];
#define NORM_ANGLE(ang) ((ang) & 2047)
#define ANGLE_2_PLAYER(pp,x,y) (NORM_ANGLE(getangle(pp->posx-(x), pp->posy-(y))))
#define NORM_Q16ANGLE(ang) ((ang) & 0x7FFFFFF)
int StdRandomRange(int range);
......
......@@ -1542,7 +1542,7 @@ DoPlayerCrawlHeight(PLAYERp pp)
void
DoPlayerTurn(PLAYERp pp)
{
short angvel;
fix16_t q16avel;
#define TURN_SHIFT 2
......@@ -1598,15 +1598,15 @@ DoPlayerTurn(PLAYERp pp)
return;
}
angvel = fix16_to_int(pp->input.q16avel) * PLAYER_TURN_SCALE;
q16avel = fix16_smul(pp->input.q16avel, fix16_from_int(PLAYER_TURN_SCALE));
if (angvel != 0)
if (q16avel != 0)
{
// running is not handled here now
angvel += DIV4(angvel);
q16avel += fix16_sdiv(q16avel, fix16_from_int(4));
pp->q16ang += fix16_from_int(DIV32(angvel * synctics));
pp->q16ang = fix16_from_int(NORM_ANGLE(fix16_to_int(pp->q16ang)));
pp->q16ang += fix16_sdiv(fix16_mul(q16avel, fix16_from_int(synctics)), fix16_from_int(32));
pp->q16ang = NORM_Q16ANGLE(pp->q16ang);
// update players sprite angle
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment