Alright, thanks.
So what I've done is whenever the window is activated, the timer is set to true, otherwise, it's set to false.
Then, I do my drawing in the timer tick function. I set the interval of Timer Tick to 1; but it still does not call anywhere near as often as my while loop did. However, this works for me as because it doesn't tick often, it gives me an effective framerate of 64 FPS.
However, Because my game doesn't draw at 500 fps anymore, It's quite jumpy to move the view so i can see all parts of the map.
Previously this would result in a clean movement of the map:
if (Keyboard
.IsKeyPressed(Keyboard
.Key.Left)) view
.Move(new Vector2f
(1
.25f,
0)); However, the only way I can produce a scrolling speed that I'm happy with is to do this:
if (Keyboard
.IsKeyPressed(Keyboard
.Key.Left)) view
.Move(new Vector2f
(10
.0f,
0)); But it is quite 'jumpy', so I need a way to smooth it out. Since my timer is a millisecond timer, and I already have it set to 1, that's as fast as I can get the timer to tick.
Do you have any idea how I could do this?
P.S. by doing this, I've got my engine down from 12-17% CPU usage to less than 0.1% CPU usage.