Path: chuka.playstation.co.uk!news From: Andrew Partington Newsgroups: scee.yaroze.freetalk.english Subject: Re: auto_arc_tan - help!! Date: Tue, 01 Apr 2003 16:12:35 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 40 Message-ID: References: NNTP-Posting-Host: public2-ward1-6-cust140.oldh.broadband.ntl.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en In-Reply-To: Doesn't matter - sussed it :) Just forgot to subtract my screen coordinates, result being that there was only ever one quadrant being considered due to both arguments being positive, d'oh!! Andy Andrew Partington wrote: > Hi all, > > I'm trying to do a collision detection/response routine which detects > which side a sprite will bounce off a background block, based on the > range of angles returned by auto_arc_tan - i.e. if the angle is between > +45 degrees and -45 degrees from 0, then the player has hit the top of a > square block, etc. > > I draw a GsLINE from the centre of the player to the centre of the block > I just collided with, and that's the angle I need. > > The player is always in the centre of the screen (i.e [160,128]), and > the end of the GsLINE is the centre of the block. The line is never > more than 64 pixels long (a 64 pixel long line would put the player at > the far edge of the block). > > I'm trying auto_arc_tan with (line.x1, line.y1), but I only ever seem to > get a range of values within a certain quadrant (e.g. 0-90 after > dividing by 46608 to get the result in degrees). Changing the sign of > the arguments shifts the quadrant round as you expect, but i'd like to > avoid writing extra code to check which side of the block we are on, > since I want to do it this way to tell me that information anyway! > > Am I using the function wrongly? Should I be using a different one? It > seemed as though it was the function to use, since some of you guys have > used it to tell you what direction the analogue stick was pointing in. > > > Cheers all > > Andy >