Sender: nate AT cartsys DOT com Message-ID: <36856D22.9F3965BF@cartsys.com> Date: Sat, 26 Dec 1998 15:11:30 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.35 i486) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: StarMaps References: <3 DOT 0 DOT 6 DOT 32 DOT 19981225124707 DOT 007aaec0 AT tenforward DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Mad Cow wrote: > > humm..I'm a novice djgpp'er, and need some help on somethin' > > i want to make a StarMap, uh, like so-- > > 1 2 3 4 5 6 7 8 9 0 > A * * * * * * * * * * > B * * * * * * * * * * > C * * # * * * * * * * > D * * * * * * * * * * > E * * * * * * * * * * > F * * * * * * * * * * > G * * * * * * * * * * > H * * * * * * # * * * > I * * * * * * * * * * > J * * * * * * * * * * > > This is a game i want to make, i want to have it so that ppl can > move a ship from > say C3 to H7 but, how do i make a thing to calculate distance, and > maybe even a path? > say the distance would be 5, and the path would be C3-D4-E5-F6-G7-H7, so, > please help > on this one..all help is deeply apreciated.. The distance between two points in a plane is `sqrt(x^2+y^2)', so #define SQ(x) ((x) * (x)) double distance(double x1, double y1, double x2, double y2) { return sqrt(SQ(x1-x2) + SQ(y1-y2)); } and round to int as appropriate. To determine the path, you want a line drawing algorithm. Breshenham's algorithm (sp?) is the best known; search for it. You could also look at the sources of a graphics library like Allegro and see how it's done. You just have grid squares instead of pixels. -- Nate Eldredge nate AT cartsys DOT com