Date: Thu, 8 Oct 1998 18:25:52 +0200 (MET DST) From: Wojciech Piechowski To: djgpp AT delorie DOT com Subject: Re: Tank Movement In-Reply-To: <6vh0su$5b7$1@ash.prod.itd.earthlink.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Chris Brooker wrote in message <36147a32 DOT 10039817 AT ct-news DOT iafrica DOT com>... >Hi, >Sorry if my code sucks, I a mquite new to C. >I am busy writing a Real Time Strategy ... >double dir_degrees(int x1, int y1, int y2, int x2) >{ > int v1, v2; > double dir; > v1 = y1 - y2; > v2 = x1 - x2; > if (v2 == 0) > v2++; //Stops division by zero errors > dir = 57 * atan(v1 / v2); > return dir; >} I would rather do this: double dir_degrees(...) { return atan2(y1-y2, x1-x2) * 180/M_PI; } --------------------\ Wojciech Piechowski /---------------------------- Student informatyki \ voyt AT ds2 DOT pg DOT gda DOT pl / Student of computer science Politechnika Gdanska \________________/ Technical University of Gdansk