
[ad_1]
I investigate source code old game for 90s, dont understand math stuff.
#define W2V_SHIFT 14
#define PREDICTIVE_SCALE_FACTOR 14
{
z = (enemy->pos.z_pos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_cos(enemy->pos.y_rot) >> W2V_SHIFT)) - (item->pos.z_pos + (object->pivot_length * phd_cos(item->pos.y_rot) >> W2V_SHIFT));
x = (enemy->pos.x_pos + (enemy->speed * PREDICTIVE_SCALE_FACTOR * phd_sin(enemy->pos.y_rot) >> W2V_SHIFT)) - (item->pos.x_pos + (object->pivot_length * phd_sin(item->pos.y_rot) >> W2V_SHIFT));
}
angle = phd_atan(z, x);
“enemy” is object on scene, for example main game character. “item” is for example tiger. Tiger attacks main character. This source code uses fixed point math (shift with W2V_SHIFT). y_rot – rotation angle. x_pos and z_pos – position on scene. phd_sin and phd_cos – assembler fixed point math routines.
My question is – what is the results x and z in this math calculations (suppose)? And what is angle variable? Is this a next coordinate to move character, or what? For what in this calculations is cos() and sin()? May be x and z is distance between tiger and main character?
Definition of phd_atan() is:
;******************************************************************************
;* Int phd_atan( int x,int y );
;*
;* Entry EAX: Distance along X axis..
;* EDX: Distance along Y axis..
;* Exit EAX: Angle ( 0 - 65536 )
[ad_2]