|
pivot sprite help |
MSGleader
Member #6,637
December 2005
|
ok, in my game i have a tank, and your looking at it from the side. and im trying to pivot the turret sprite so the turret rotates just like in the game pocket tanks, or the game worms, where you can aim everywhere... if im making any sense here, you should understand what i mean. im having troubles with my pivot angle stuff... i have : pivot_sprite(buffer,turret_bmp,tanks[0].x+15,tanks[0].y+2,2,14,ftofix(tanks[0].angle)); textprintf_ex(buffer,font,20,320,makecol(255,0,0),-1,"Angle: %d",ftofix(tanks[0].angle));
The turret rotates... but when i want to show the angle it is at on the screen. my tanks[0].angle is just a float number. and i add 1 to it when i press right, and subtract 1 from it when i press left... is there a special way to do this stuff, or am i just doing everything wrong? |
Jonny Cook
Member #4,055
November 2003
|
%d is for integers. You want to use %f. Try this: "Angle: %.2f". Go here for more info. [edit] textprintf_ex(buffer,font,20,320,makecol(255,0,0),-1,"Angle: %.2f",tanks[0].angle); Assuming tanks[0].angle is indeed a float (or double), that should work. ftofix converts a float to a fixed point number. You only want to do that when, well, you need a fixed point number. In this case you don't. The face of a child can say it all, especially the mouth part of the face. |
MSGleader
Member #6,637
December 2005
|
thanx, i tried that, and it works now! |
Tobias Dammers
Member #2,604
August 2002
|
To make it even more human-readable, you'll want to convert from allegro's 256-deg format to the usual 360 degrees: textprintf_ex(buffer,font,20,320,makecol(255,0,0),-1,"Angle: %.2f",tanks[0].angle * 360.0f / 256.0f);
--- |
|