Message-Id: <3.0.6.32.19981225161913.007beb10@tenforward.com> X-Sender: sw AT tenforward DOT com X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Fri, 25 Dec 1998 16:19:13 -0800 To: djgpp AT delorie DOT com From: Mad Cow Subject: Re: StarMaps In-Reply-To: <002701be305c$4794a140$ecf8c6c3@johans-dator> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com Ouch! My Brain Hurts! >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. > >