Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


help me please??

This topic is 5963 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

I am confused by the structure of my OpenGL (with GLUT) program. I am hoping to create a breakout-style game but have run into problems animating things. If someone could provide some guidance as to how I smoothly animate the paddle it''d be a great help. So far the Paddle class looks like this:

class Paddle
	Paddle( );
	Paddle( PADDLES );
	~Paddle( );

	void drawPaddle( );
	void movePaddle( GLfloat movement );

	PADDLES type;
	Vector3d* currentLoc;
	GLint width;
At present the paddle moves, but in noticable increments of 2 (the value passed to movePaddle() ). How should I go about making it move smoothly? Do I need a fine movement variable like Nehe used in tutorial 21? The renderScene function only calls the drawPaddle() function and movePaddle() is called in response to the key presses, is this correct? Some advice would be greatly appreciated, I have been stuck for ages and its killing my love of programming

Share this post

Link to post
Share on other sites
You need to use a timer and update positions of your objects based on the time passed between current and previous frames. You also need to use DirectInput or check for keys being up/down, as opposed to handling Windows messages. Take a look at GetAsyncKeyState.

BTW: NeHe''s code relies on v-sync being on. As soon as I turned it off and framerate jumped from 85 to 300 fps, all his cubes have been spinning like crazy.

Share this post

Link to post
Share on other sites
1. Fix your driver settings. For NVIDIA: display settings-settings-advanced-geforce 3 or whatever-additional properties-opengl.

2. WGL_EXT_swap_control extension.

Share this post

Link to post
Share on other sites
I am still a little cofused. Can someone post some example code showing how to use frames in my GLUT program. My current timer callback function looks like this:

void timer( int i )
ball.moveBall( );
glutTimerFunc( 20, timer, 1 ); //resets the timer function
glutPostRedisplay( );

Is this all I need to create a constant refresh rate?? This doesn''t looks as good as when I used the idle function either. And still the paddles isn''t being moved smoothly!!

Share this post

Link to post
Share on other sites

  • 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!