PDA

View Full Version : Help with some simple 2d transformations



11-18-2005, 06:45 PM
hi, right now i need some help. i have a 2d birds-eye view game with the player placed in the center. So i transform and rotate everything around him. The only problem comes with other players. Right now how it's set up, they all face up. But i want them to face where their angle says they're truely facing. So in my code i have a for loop that goes through all the players like this:



glRotatef( gp->players[ gp->myIndex ].angle, 0.0, 0.0, 1.0 );
glScalef( gp->scaleFactor, gp->scaleFactor, 1.0 );
glTranslatef( -gp->players[ gp->myIndex ].position.x, -gp->players[ gp->myIndex ].position.y, 0.0f );

( myindex is the index of the observing player )

and this transforms everything but all the players are facing up. I need to place a glrotate in there somewhere but i can't figure out where to make it work right. i need to use the angle variable (which has the angle of the current player in the for loop) somewhere in that rotate statement too. Any help would be appreciated. one of the combinations i thought would work i tried but to no avail:



glRotatef( angle, 0.0, 0.0, 1.0 );
glRotatef( gp->players[ gp->myIndex ].angle, 0.0, 0.0, 1.0 );
glScalef( gp->scaleFactor, gp->scaleFactor, 1.0 );
glTranslatef( -gp->players[ gp->myIndex ].position.x, -gp->players[ gp->myIndex ].position.y, 0.0f );

11-19-2005, 05:50 AM
You mean like sprites? Rotate billboards so they're facing the player?