I've made a simple 2D game engine using C# and DirectX and it's fully functional for the demo I made to test it. I have a Timer
object that uses QueryPerformanceCounter
and I don't know what's the better choice: use only one timer in the game loop to update everything in the game, or an independent timer in every object that needs one.
My worry is that when I try to implement threads, what will happen with timers? What happens with the sync?
You had better to have an Update (user interaction and other calculatings like hittest) and Draw functions for each game object. Your timer should call the topmost Update method and this method will call the update methods of each object. Drawing can be done with another timer or just a while loop until game ends. My choice is having only one timer for update. For the differences of timers; Comparing the Timer Classes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With