rotation problem

Hi im rotating a swing and i only want it to an angle of 40 and then back but at the moment the swing is just going all around.I put an IF statement in but it doesnt seem to be working

glTranslatef(0,0,-50);
drawBar();

glRotatef(rotate,60,0,0);
glPushMatrix();
	glTranslatef(2,0,0);
	glRotatef(rotate,1,0,0);
	glTranslatef(0,-12,0);
	drawRope();
	glTranslatef(5,0,0);
//	glRotatef(rotate,1,0,0);
	drawSeat();

	glTranslatef(0,12,0);

	drawRope2();		

	glPopMatrix();	

// Make the it swing back or forth depending upon direction
if (direction == 1)
angle++;
else
angle–;

// Change the direction if 40 or -40 is reached
if (angle == -40.0) {
	direction = 1;
}
if (angle == 40.0) {
	direction = 0;

after a quick look at your code…

you shouldnt use == with floats…round off errors could mean that this equality will never happen…

if you need to use floats…use >= and <=…

also,maybe this is just a typo, but, you use “rotate” in your glRotate function, but “angle” when checking it

[This message has been edited by bumby (edited 11-27-2003).]

Thanks i got it working.Would you know how i rotate the seat with out moving the ropes.At the moment when i try to rotate the seat the ropes are moving aswell.
glTranslatef(0,0,-30);
drawBar();
//rotate the rope and swing
glRotatef(0.0,0,1,0);
glPushMatrix();
glTranslatef(2,0,0);
glRotatef(angle,1,0,0);

	glTranslatef(0,-12,0);

//glRotatef(rotate2,1,0,0);

	drawRope();
	glTranslatef(5,0,0);
		//glRotatef(rotate2,1,0,0);
	drawSeat();
	//	glRotatef(rotate,1,0,0);
	glTranslatef(0,12,0);

	drawRope2();		

	glPopMatrix();

surround your seat drawing and translation code with glPushMatrix and glPopMatrix…

dont have time to get into it more…but maybe that wil help you a little.