Well basically I had to recreate the game space invaders for a task today. The game it self comes out fine. But one of the tasks to implement is "frames per second" into this game.
I'm not to sure how to start adding something like this into a console program. The program was made with a 2D array and structs for the invaders etc. I have a players ship that shoots bullets when you tell it too. All of this is made in the console. But it runs on the speed depending on the computer as its just constantly doing everything.
Thus making the game to fast - so the task at hand is to add fps to it. Just wondering if anyone can point me in the right direction or show me an example of how to implement this using just c++. No extra stuff like SDL's FPS functions and what not.
That should be defined in ctime and it holds the number of clocks in a second
If clock()-before == CLOCK_PER_SEC then a second have passed since you gave a value to "before"
If your using windows. Use the GetFrequencyCounter() API calls within your game loop. They give you a much higher level of accuracy and are used by most modern games.
Ah I've seen this used before I'll check it out now. Thanks
EDIT:
Just wondering Zaita if you have any sites or anything that explains this function a little more. I seen it used a little while ago but I can't find my mates code he used it in. Any sites or what not would be great as googles giving me trash on it at the moment.