Path: chuka.playstation.co.uk!news From: "John \( QuietBloke \)" Newsgroups: scee.yaroze.freetalk.english Subject: Re: Daft Question [long] Date: Sun, 26 Aug 2001 00:26:30 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 74 Message-ID: <9m9c88$ioj5@www.netyaroze-europe.com> References: <9loc6a$p3k2@www.netyaroze-europe.com> <9loeu8$p3k3@www.netyaroze-europe.com> <01c1297e$8cb6e8a0$LocalHost@pal-s-omnibook> <9lrqqf$3j63@www.netyaroze-europe.com> <01c129ca$a5a6f700$d81fe4d5@pal-s-omnibook> <9m1d9c$b2i7@www.netyaroze-europe.com> <01c12ceb$fba64880$9709e4d5@pal-s-omnibook> NNTP-Posting-Host: host213-122-191-50.btinternet.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Good point.. in fact the pause would probably make for a more realistic response. btw.. all that stuff I wrote about shifting etc.. it really was twaddle.. I had a bit more of a think about other solutions and I have a nice simple elegent one which should still be pretty quick... quicker then all them if's and shifts and stuff ! Havent written it yet ( Ive been mucking around with the crap graphics again.. trying to make them look reasonable ) but it goes something like this. I keep the table just as you got it but in the function : long getAngleForXY(int dx, int dy, long currentAngle) int tmpx, tmpy, tmp tmpx = abs(dx); tmpy = abs(dy); tmp = (tmpx XYRange ) { tmp = ( tmp + XYRange -1 ) / XYRange; dx = dx / tmp; dy = dy / tmp; } return angleForXY[dy+XYRange][dx+XYRange]; } So : for example if XYRange = 16 and dx = -17 and dy = 4 then tmp = ( 17 + 16 - 1) / 16 which is 2 therefore dx = -17/2 = -8 dx = 4/2 = 2 voila... the function will work.. OK.. so it doesnt end up with a brilliant position in the table but its quick. The worst case would be this particular one where I end up in the middle of the table. Im gonna have to try it to make sure it doesnt end up giving me wobbly results but increasing the table size should reduce it. Dunno if this is of interest to anyone but what the heck.. Im sitting taking a break from drawing so I thought Id share my thoughts. Cheers John ( QuietBloke ) "pal" wrote in message news:01c12ceb$fba64880$9709e4d5@pal-s-omnibook... > John ( QuietBloke ) wrote in article > <9m1d9c$b2i7@www.netyaroze-europe.com>... > The only change I am going to have to do is that as I am > > trying to find the angle between a bug and its target ( whatever it may > be ) > > the distance may be quite large.. > > Oh, yes, I had'nt thought about that. I just needed the angle to properly > rotate a ship according to its deplacement. This will make a difference... > > >and I end up with 30-40 bugs calculating new directions each frame. > > What about not calculating every frame? A bug changing direction only once > in ten or whatever frames should'nt make a visible difference; this makes > for a cheap and big processor time saving. > > No other suggestions for now... > > pal >