Basic Physics and Ball

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?

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?

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).]

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…

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.