Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "John Emmer" Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: Algorithm to orbit? Date: 5 Aug 1997 06:30:37 GMT Organization: Justice Center Lines: 43 Message-ID: <01bca151$50db3f20$e7f135ce@jjustice.iquest.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> Reply-To: "John Emmer" NNTP-Posting-Host: and-002-14.iquest.net X-Newsreader: Microsoft Internet News 4.70.1161 Scott Cartier wrote in article <33E69E15.75F8@concentric.net>... > I see why this is so tricky. Lets say your tank doesn't move, > but rotates about its center. Since the turret is not on the > tank's center, but say X pixels from the center, it could be > anywhere on the circle of radius X with its center on the tank's > center. Did I get that right? > > If so, I don't see an easy way to do it (at least with the > library routines). Without thinking too hard - something I'm > good at - I would make up a quick 360 entry table to represent > the turret's offset relative to the center of the tank at every > angle the tank could be at (if it can move in increments less > than 1 degree then you're talking about more table entries). > To save space you could cut that table to 1/8 it's size and > play tricks with swapping X-Y values, and negating X and/or Y > values. I have a similar table for my game. > 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. 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? -- John Emmer Video Game Enthusiast, Philosopher, Fledgling Programmer jjustice@cs.bsu.edu jjustice@iquest.net jpemmer@bsuvc.bsu.edu Vectrex; 7800, Supercharger, Lynx, Jaguar; NES, SNES, Virtual Boy; Turbo Duo & Express; SG, SGCD, 32X, Saturn; 3DO; PlayStation, Yaroze; C64, A600, A1200, P100; Arcade Centipede, Spy Hunter, Neo-Geo; BA, MA, ABD