Message-ID: <002701be305c$4794a140$ecf8c6c3@johans-dator> From: "Johan Henriksson" To: Subject: Re: StarMaps Date: Sat, 26 Dec 1998 00:14:09 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com -----Original Message----- From: Mad Cow To: djgpp AT delorie DOT com Date: Friday, December 25, 1998 10:23 PM Subject: StarMaps >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.. Hello sickness (Sorry, just a *sick* joke :) To calculate the distance between two points in 2D-space, you use the pythagorean theorem. I give you some code from X-type: int get_distance(int x1, int y1, int x2, int y2) { return(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); } This function returns the distance between x1,y1 and x2,y2... short int gox,goy,speed; float del; del=speed/sqrt((x-gx)*(x-gx)+(y-gy)*(y-gy)); gox=-((float)((float)x-(float)gx)*del); goy=-((float)((float)y-(float)gy)*del); ...and this piece o' code returns the path for a bullet or something like that. Set the speedvariable to pixels it will move every time. Every time you want to move it, do x+=gox and y+=goy. Well good night as we say here 00:12. > > > > >