Aye I know its pretty messy because there's a lot of other code here and there and I didn't paste the complete class (which would be VERY long :P )
I have a separate console window to output my printf for debugging purposes.
AllocConsole(); freopen("CONOUT$", "wb", stdout);
and I am using VS2005 and trying my best to debug things
Hmm, about the conversion, should I just convert the return of
float Player::unsigned_angle(CVector2 a, CVector2 b){ return abs(atan2(perp_dot(a,b), vec_dot(a,b)));}
so that it will return a value in degrees? For example:
return RAD2DEG(abs(atan2(perp_dot(a,b), vec_dot(a,b))));
edit: Will attempt to explain the code out a little :P
bool Player::Attacked(float x, float z, float r, CVector2 Tarpos, CVector2 TarOrient, float tarFOV )
is basically the star of the show. It's called every frame and compared to all the alive zombies (not so efficient I know:P) which at the moment is just one. Zombies like the player have 3 important stats, their pos (ZXplane), their orientation(0-1 range on the ZX plane) and lastly the radius (for bounding circle computation). At the present, the zombies don't move/turn at all.
Float x,z in this function is the zombie's pos, float r is the zombie's radius. Tarpos means the zombie's position again as CVector2 type, TarOrient is the zombie's orientation (0,1 etc etc) and the fov is the zombie's FoV in degrees.
Player::Attacked first test for Bounding Circle comparing the player's current pos and the zombies. If that passes , it will then test for fov using
bool Player::check_fov(CVector2 Zombiepos, CVector2 zombieOrient, float zombiefov, CVector2 playerPos)
This is basicallly the code that you showed me earlier except I use the player as the "target" here. If that passes as well Player::Attacked will return positive. It will return false in all other circumstances. Player::Attack is specifically just used to see if the player is attacked by zombies.
Zombiepos = the zombie's position, zombieOrient = the zombie's orientation, zombiefov = zombie's fov. Yeah I know the naming conventions are very confusing and probably the code is not efficiently or well written but I am just trying to keep things simple and of course make it work :P
Hmm I hope that cleared things up a bit .Will do further testing but its all numbers at the moment and as you probably know I am not so good with numbers :(
This is a game for the visually impaired so there's no graphics to compare or debug with.