Forum archive
Revolving sectors and sprites that move around with it.
- So I'm still working on Unkillable, and wanted to make it so that any sprite that's put into a revolving sector (as used for the revolving doors in KenBuild) moves along with it. As I'm sure you can all remember, I am not much of a mathematican so I'm very glad to have the RotatePoints function but that's not much help here.
So basically, when a sector is moved around by a tag or SE, how do I make the sprites "stick" onto it, assuming they are on a relativily-aligned floor?
...where do "making your own Build game" questions go anywhere? - This would be my solution:
//This is just for simplicity. Ideally, you would only want
//to allocate memory for sprites that are in a rotating sector.
long origspritex[MAXSPRITES];
long origspritey[MAXSPRITES];
//After loading the board, save the original coordinates of
//any sprites that are in a rotating sector. If you don't do
//this, your sprites will drift off course very quickly.
origspritex[?] = sprite[?].x;
origspritey[?] = sprite[?].y;
...
//In your movement code:
short s;
int sectorindex = ?, pivotx = ?, pivoty = ?, pivotang = ?; //You fill these in
for(s=headspritesect[sectorindex];s>=0;s=nextspritesect[s])
rotatepoint(origspritex[s],origspritey[s],pivotx,pivoty,pivotang,&sprite[s].x,&sprite[s].y);
Please note that I have not actually tested this code in game. It's just to get you started. - Woo! Thanks! I'll have to try this out...
There's only one more thing I'd like to know... how to make this work for sprites that suddenly enter the sector, like the player and the enemies chasing you.