Gerard Krol schreef:
> ## line 135: Can someone explain how you can get a reminder after devision by 
> 1? (should be %2)
> +     //Random direction(left or right 30 degree's)
> +     if (rand()%1 == 0)
> +     {
> +             angle += 30;
> +             if (angle >= 360)
> +             {
> +                     angle -= 360;
> +             }
> +     }
> +     else
> +     {
> +             angle -= 30;
> +             if (angle < 0)
> +             {
> +                     angle += 360;
> +             }
> +     }
>
> Also, why not write: angle = (angle-30)%360;
>   
Same applies for the +30 degree part, so this would probably suffice:
> angle = (rand()%2 == 0) ? (angle + 30) % 360 : (angle - 30) % 360;
I'm just using the ternary operator (`?') here because that's my taste
for this use: it emphasizes what happens, namely an assignment rather
than true branching. Though `if' will do just fine as well.

Also, what is turning left and what right here? (I.e. a comment for both
branches of that `if' would help, e.g. angle += 30; // turning right here.)


Then one of my own remarks, on the subject of magic numbers, line 126 of
your patch:
> +    angle = (SDWORD)(atan2f((float)xdiff,(float)ydiff) * 180 / 3.14f);
Why are you using 3.14f here? Why not just M_PI? Every C99 compiler
should define it and otherwise the framework include files make sure to
do so (conditionally defined by framework headers).

-- 
Giel

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to