PDA

View Full Version : Basic Physics and Ball



DragonXTC
04-26-2002, 07:25 AM
I am working ona pinball game but im kinda stuck, could someone tell me where i would want to stick the ball function at? meaning where could i put the function so that is updates the ball constantly but i can stiull interact with the flippers? anyone got any ideas?

nexusone
04-26-2002, 08:31 AM
You should have one function that handles all object.

my_object_manager() // call with something like glutTimerFunc, glutIdleFunc.
{

if (flippers) // Check if flippers need to be updated.
{
make changes to flippers here.
}

if (ball) // Check for ball update of course we always update flippers first since you have to check for flippers current position to see if ball is hitting them.
{
Do ball changes here, check to see if ball has hit a wall or our flippers.
}

Update_display(); // We only redraw screen after processing all objects and at this point and at no other place.
}

Make sense?
http://www.opengl.org/discussion_boards/ubb/smile.gif


Originally posted by DragonXTC:
I am working ona pinball game but im kinda stuck, could someone tell me where i would want to stick the ball function at? meaning where could i put the function so that is updates the ball constantly but i can stiull interact with the flippers? anyone got any ideas?



[This message has been edited by nexusone (edited 04-26-2002).]

nickels
04-26-2002, 09:31 AM
I think what you are asking is answered by this:

You should make your glut idle function call your ball movement routine (i.e. move it just a little each frame).

Or if in win32 set up a timer call back; or just process a few events each frame, do some integration, process a few more events, etc...

Zuraffo
04-28-2002, 12:53 AM
You could also use your draw callback to do the updating, then in the idle callback just invoke a glutPostRedisplay().

Then the stick should get the signal from keyboard callback and get updated at the same place.

It's really up to your personal preference.