Original Post
if(keys['A']) //strafe left
{
if(xpos>-2.3 && xpos<2.3)xpos += (float)sin((heading-90)*piover180) * 0.25f;
else if(xpos<-2.3 && ((90<=heading && heading<=270) || (heading<=-90 && heading>=-270)))
xpos += (float)sin((heading-90)*piover180) * 0.25f;
else if(xpos>2.3 && (abs(heading)<=90) || heading>=270 || heading<=-270)
xpos += (float)sin((heading-90)*piover180) * 0.25f;
zpos += (float)cos((heading-90)*piover180) * 0.25f;
}
Heading is the player's direction in degrees. And it resets when it hits 360 or -360.
For some reason, when -270>=heading>=-360 it allows me to strafe left! Perhaps I'm missing something, but i was under the impression that the compiler did Nots, Ands, Ors in that order. So I added parentheses, and it still lets me strafe left! The conditions to strafe left aren't being met, so I don't know why it's changing xpos. This has me baffled, if you see something I don't, please point it out. Thanks.
DON'T COPY THAT FLOPPY!
[edited by - MillaTime on July 23, 2003 5:30:20 AM]
[edited by - MillaTime on July 23, 2003 5:31:02 AM]