Path: chuka.playstation.co.uk!news From: richard.cutting@virgin.net (Richard Cutting) Newsgroups: scee.yaroze.beginners Subject: Re: angles, angles Date: Wed, 18 Nov 1998 10:01:01 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 35 Message-ID: <3652971c.228584498@news.playstation.co.uk> References: <72spa7$dvm12@chuka.playstation.co.uk> <72sr28$dvm13@chuka.playstation.co.uk> NNTP-Posting-Host: p38-guillemot-gui.tch.virgin.net X-Newsreader: Forte Free Agent 1.11/32.235 On Tue, 17 Nov 1998 21:50:40 -0000, "Darren Jackson" wrote: >HHmmm... > >The previous message isn't quite right, I am confusing myself at the minute >!! > >The thing is how do I get the correct x and y values according to the angle. >I know that x and y can only be integers but I need to know how many pixels >across for every one up, for example. ( I have had a hard day at work and I >trying to figure this out now!!). > >Darren > > To compute the trajectory the following bit of maths is used; xv = sin( angle ) * magnitude yv = cos( angle ) * magnitude ( where angle is the angle relative to the horizon and magnitude is the overall speed of the sprite in pixels per game cycle ) If you apply xv and yv to your sprites x and y co-ordinates the sprite will move in a straight line path from its point of origin. To get around the floating point problem you'll need a fixed point trig library. There are a couple floating around, two I know of can be found at http://www.netyaroze-europe.com/~shaughnj or http://www.netyaroze-europe.com/~nslaven Richard.