mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
sw/src/player.cpp:DoPlayerTurn: Increase turning precision
with q16 angle. This uses the new NORM_Q16ANGLE macro.
This commit is contained in:
parent
1a46afaf27
commit
8284fcba9a
2 changed files with 7 additions and 6 deletions
|
@ -445,6 +445,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);
|
||||
|
|
|
@ -1538,7 +1538,7 @@ DoPlayerCrawlHeight(PLAYERp pp)
|
|||
void
|
||||
DoPlayerTurn(PLAYERp pp)
|
||||
{
|
||||
short angvel;
|
||||
fix16_t q16avel;
|
||||
|
||||
#define TURN_SHIFT 2
|
||||
|
||||
|
@ -1594,15 +1594,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
|
||||
|
|
Loading…
Reference in a new issue