Original Post
I need some help with a problem.
I have made a little demo with a background and a cube thats spinnning infront. My problem is that i want the cube to move from the middle(It´s positioned there from the begining) to the right edge and there change direction and move to the left edge and there change and move to there right and so on.
I know how to move the cube with the command
gltranslatef(x,y,z);
for example
gltranslatef(xmov,0.0f,-5.0f);
and then make xmov+=0.01f;
so the cube moves to the right.
I have tried something like
if (xmov==(4.0f)
{
xmov-=0.01f;
}
so it would change direction when the xmov=4.0f which is at the right edge of my window.
but it doesn´t work.