Jump to content
  • Advertisement
Sign in to follow this  
fooman_69

circular issues

This topic is 4782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hiya, I need to be able to rotate a quad in openGL between the 270 and 90 degrees, so half of a circle. Why do these methods not work for me??
void Entity::IncreaseAngle()
{
	if(ammoStr.degree > 360)
		ammoStr.degree -= 360;
	if((ammoStr.degree > 269) || (ammoStr.degree < 91))
		ammoStr.degree++;

	return;
}

void Entity::DecreaseAngle()
{
	if(ammoStr.degree < 0)
		ammoStr.degree += 360;
	if((ammoStr.degree > 269) || (ammoStr.degree < 91))
		ammoStr.degree--;

	return;
}
I start out at 90 degrees. I'm not sure why this is not working... the quad gets stuck at one end of it's rotation (stuck at 270 degrees). From there it won't move anywhere.

Share this post


Link to post
Share on other sites
Advertisement
If you only want it to move between 90 and 270, then why overcomplicate it? Since the entity can't move outside of that range, there's no reason to do boundry checking.


void Entity::IncreaseAngle()
{
if(ammoStr.degree < 270)
ammoStr.degree++;
return;
}

void Entity::DecreaseAngle()
{
if(ammoStr.degree > 90)
ammoStr.degree--;
return;
}



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I guess you never really printed out the value when you reached the endpoints.
What was happening was that when you thought that you were at 270 degrees, you were really at 271 thus it was outside of your 270 - 90 degree intended range so you could not decrease the angle.


void Entity::IncreaseAngle()
{
if(ammoStr.degree > 360)
ammoStr.degree -= 360;
if((ammoStr.degree >= 270) || (ammoStr.degree < 90))
ammoStr.degree++;
// value can increase to 361, depending on the rest
// of the code you may want to subtract 360 degrees.
// The rotate functions wont be bothered by this but
// if you display it anywhere on the screen, some people may wonder.

return;
}

void Entity::DecreaseAngle()
{
if(ammoStr.degree < 0)
ammoStr.degree += 360;
if((ammoStr.degree > 270) || (ammoStr.degree <= 90))
ammoStr.degree--;
// value can decrease to -1, depending on the rest
// of the code you may want to add 360 degrees.
// The rotate functions wont be bothered by this but
// if you display it anywhere on the screen, some people may wonder.

return;
}





Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!