Hey, I'm trying to make my first game in c using openGL: pong (might as wel start with the basics).
I have the logic figured out for the bouncing but I can't find a proper method for the timing (making the ball move every x milliseconds). I've tried using time() and difftime but that returns a value in seconds and moving the ball every second makes for a veeery slow game .
Now I've tried gettimeofday() which works for a second or 2 and then it just stops working and the ball stops moving...
This is the relevant part of my code. I've tried finding sollutions online but I'm still relatively new at this so I can't really understand most of the things i find (and it's usually in c++ instead of c)
In the main to be run once before all of the opengl functions:
struct timeval now, before;
My timing function. If go is 1 the ball can move:
When I used time() and difftime before, the ball would not move but the commented printf would still printf the time repeatedly, even if I set the difference to 10000 seconds.
//printf("%lf\n", difftime(now, before));
Can anyone give me some hints?