Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Scott Cartier Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Algorithm to orbit? Date: Tue, 05 Aug 1997 15:57:41 -0700 Organization: SCEA Net Yaroze News Lines: 39 Message-ID: <33E7AFE5.6EA0@concentric.net> References: <01bca03a$5c9d6ee0$8bf135ce@jjustice.iquest.net> <33E4E1EE.7CE0791A@ix.netcom.com> <01bca043$beb64300$8bf135ce@jjustice.iquest.net> <01bca04f$83feb6a0$8bf135ce@jjustice.iquest.net> <33E69E15.75F8@concentric.net> <01bca151$50db3f20$e7f135ce@jjustice.iquest.net> Reply-To: dsyaroze@concentric.net NNTP-Posting-Host: ts022d20.cup-ca.concentric.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0C-GZone (Win95; I) > Yes, you got it, and thanks, now I see that I need to include > the tank's rotation in my calculations. In the routine that I posted, I > had failed to account for the fact that, once the tank has rotated, it's > 'upper left' corner - where the screen coordinates are pointing - is no > longer in the upper left position. I was simply calculating the offset > from the upper left corner as if it were actually always higher and left of > the center of the turret, but of course once the tank rotates, this is no > longer the case. Yep, and unless you have lots of CPU cycles to spare, I'd use a lookup table as opposed to doing the sin/cos calculations. > Let me state this explicitly then just to be sure I understand what is > happening here. If I take a sprite and rotate it, it's screen coordinates > will also change to reflect the fact that the upper left corner (given the > orientation of the of the original image) has moved -- instead of -- when I > rotate a sprite, it's coordinates remain the same and the part of the image > that is considered 'upper left' is whatever part of the image is actually > now highest and leftmost on the screen - right? Here's how I understand it. The sprite components mx and my specify the "center" of your sprite. The pixel to which (mx, my) refers will be the pixel that you are moving with the x & y components. Lets say you have a GsSPRITE "sprt" which is 31 by 31 pixels and you set (sprt.mx, sprt.my) to be the center (15, 15). Now the components sprt.x and sprt.y don't refer to the upper- left corner, but to the pixel pointed to by (sprt.mx, sprt.my). So for instance, if you move your sprite to screen coordinates (100, 100), the sprite will actually extend from (86, 86) to (114, 114). The same goes for rotation. If you rotate the sprite, that one pixel will stay put, but the other pixels will rotate around it. Scott