Player Direction & Rotation
by George Lambrou · in Technical Issues · 08/27/2008 (6:58 pm) · 4 replies
I'm trying to create a simple 2D racing game, but I'm unsure of how to set (if possible) an angular direction (i.e. 90 degrees) for my player to move in (as opposed to setting x- and y-speed values,) and sprite rotation based on the direction value. If anyone could help me out, I'd really appreciate it. Thanks!
-George
P.S. Sorry, it cut off my original post at the degrees sign.
-George
P.S. Sorry, it cut off my original post at the degrees sign.
About the author
#2
08/27/2008 (8:03 pm)
You appear to have a TorqueSDK license, so I would also recommend looking at the c++ code in Player::pickActionAnimation, thats one technique for well, picking a movement animation based on the current velocity, same principle in 2d.
#3
t2dSceneObject::setImpluseForcePolar( 73, 39, false );
Is that the line of code I should insert? By the way, this is my first real programming project, so I'm really not familiar with scripting yet... But still, cheers for the help!
-George
08/28/2008 (9:04 am)
So, say i wanted to make the object move on a 73 degree angle, at a speed of 30 pixels/second, without gravity:t2dSceneObject::setImpluseForcePolar( 73, 39, false );
Is that the line of code I should insert? By the way, this is my first real programming project, so I'm really not familiar with scripting yet... But still, cheers for the help!
-George
#4
t2dSceneObject is the namespace of the method setImpulseForcePolar. You would not call it like that, you would do something like:
Where %obj is an object of the class t2dSceneobject. Which includes t2dStaticSprite, t2dAnimatedSprite, etc, all classes that derive from t2dSceneObject.
08/28/2008 (10:35 am)
Make sure what you think of as 73 degrees is really the same direction in TGB. 0 degrees would be straight up, 90 degrees would be straight to the right, 180 degrees straight down, etc.. At least I 'think' thats right.t2dSceneObject is the namespace of the method setImpulseForcePolar. You would not call it like that, you would do something like:
%obj.setImpulseForcePolar( 73, 39, false );
Where %obj is an object of the class t2dSceneobject. Which includes t2dStaticSprite, t2dAnimatedSprite, etc, all classes that derive from t2dSceneObject.
Associate James Ford
Sickhead Games
t2dSceneObject::setImpluseForcePolar( angle, force, isGravitic );