Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

OpenGL sprite jump

Recommended Posts

well I am working a jumping algorithm. I got my sprite to move up and down irratically I want it to jump up and  down smoothly. let me know if you need more info.

void spritejump()
{
	if (state == false)
	{
		jump++;
		if (jump >= 20.0f)
		{
			state = true;
		}
	}
	else if (state == true)
	{
		jump--;
		if (jump <= 0.0f)
		{
			state = false;
		}
	}
//	cout << "jump: " << jump << endl;
}

void handleKeypress(unsigned char key, int x, int y)
{
	int animate = 0;

	switch (key)
	{
	case 27:
		exit(0);
		break;
	case 32:
		animate = !animate;
		if (animate)
		{
			glutIdleFunc(spritejump);
		}
		else
		{
			glutIdleFunc(NULL);
		}
		break;

 

Share this post


Link to post
Share on other sites
Advertisement
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!