I think …
I have to programm a Text Adventure … that makes the movement easysier
for a beginner
OK,…just joking…
I use the glTranslatef Function to position my Textquad (2 Variables for x and the y
coordinates) and Z for the Rotation wich where caculated between 0.0f and 360.0f
(When the Player pressed Right or Left ZSpeed it increased or decreased with 0.001f)
But when the Player turns his ship over 360 Degrees the Variable Z grows for example
over 360.0f or under 0.0f . To get an defined Rotation between 0-360 I wrote this Lines:
to keep tracking of the Rotation:
glTranslatef(xmove,ymove,ZRotation);
-Than the Actor/Player/Textquad
-calculate the XMOVE and YMOVE ???
ZRotation+=ZSpeed;
if (ZRotation >= 360.0f) Looks if the float gets over 360
{
ZRotation = 0.0f; resets the float ZRotation on same Position
}
if (ZRotation <= 0.01f ) Looks if the float runs under 0
{
ZRotation = 360.0f; resets the float ZRotation on same Position
}
if (keys[VK_RIGHT])
{
ZSpeed += 0.001f; increase / turn left
}
if (Keys[VK_LEFT])
{
ZSpeed -= 0.001f; decrease / turn right
}
When the actor looks to the left side ZRotation is 90.0f
When the actor looks up ZRotation is 0.0f/360.0f !!
When the actor looks down ZRotation is 180.0f
but possible are all 360.0f degrees…
and so on…
for example :
When my actor has the xmove-coordinate 0.0f, ymove-coordinate 0.0f and the ZRotation
is 75.8f.
And I press my key to thrust the ship/actor/quad which inreases a Variable ACCELERATION with f.e. 0.01f
to increase the speed of the movement…so I can decrease it slowly to simulate a havy ship and
Tons of steel
for example:
if (Thrust_not_pressed)
{
Acceleration -= 0.001f;
}
How can I tell the Programm mathemathecly to move my textured quad with the glTranslatef Function in this
Direction ? Are Vectors the only way ? and…finaly
When the Actor/player/quad/Tons_of_steel_ship moves in this direction and the Player changes the Rotation
of the ship and Thrusts in any other direction…How can I calculate the new direction and the amount of
REST Acceleration (because it is a havy ship with tons of steel ) of the Player/actor/ship ?
I think it must be something with the angles (ZRotation) of the player to get the Information of the relative Acceleration
Directions , Thrust and the amount of changing the Variables for the X ans Y Axis …
Or…Is this maybe the totaly wrong way to do this ?
I don´t know…
reign_bow and grady is that what you both mean ?
Thank you both for your answers I will try these versions to solve my “little” problem…
I will be back in few hours
CU , TRM