Home Game Development c++ – What this code do?

c++ – What this code do?

0
c++ – What this code do?

[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]

Previous article Apple has a chance to fix Mac gaming for good in 2024
Next article Cyberpunk 2077 winning a “Best Ongoing Game” award feels incredibly off – Destructoid
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!