Path: chuka.playstation.co.uk!news From: "Chris Wallace" Newsgroups: scee.yaroze.freetalk.english Subject: Re: joystick directions Date: Thu, 11 Jul 2002 19:41:51 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 28 Message-ID: References: <3D28AB1D.8010407@100Tinsoldiers.com> <3D2DCC57.6000807@100Tinsoldiers.com> NNTP-Posting-Host: host217-39-11-73.in-addr.btopenworld.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Ok here is the code as i have it, you will have to work out which variables to swap over etc. target_dir=ai_map2[player[i].tile]*(ONE/8); this sets the target direction, in theis case ai_map2 is always a number from 0 to 7 so *ONE/8 is just multiplaying it to a full angle, which you should already have from tan2. dir_diff=(((target_dir-current_dir)+(ONE/2))&(ONE-1))-(ONE/2); ok, now.. i didnt strictly write this bit, i think Alex Herbert did. This will give an out put either smaller or greater than 0, which can be tested as such: if(dir_diff<0) turn_left if(dir_diff>0) turn_right; And im guessing if it = = 0, then ur already facing that direction. Hope that helps! Chris