This is simple to fix, really. And it will make your games a lot faster, especially if you have to draw a lot of objects on-screen.
This tutorial assumes you have a persistent, global control object. If not, make one now. Make sure to put it in the first room of the game. It usually is tasked with all the global variables and what not, but we are also going to use it for drawing.
In the Create or Game Start Event:
set_automatic_draw(false); //this makes it so that the game will not draw anything AT ALL, unless you tell it to ct=current_time; //cgrrent_time is in milliseconds. That is all you need to know
In the Step, Begin Step, AND End Step Event:
//34 milliseconds is 1/30 of a second rounded up. You can use 67(1/15) and 133(10/75) and so on. if current_time>=ct+34 screen_redraw(); //executes the Draw Event ct=current_time; //resets current_time to now
The catch to this is that the FPS variable will not give you the correct value.
So how does thing actually makes the game smoother and faster?
The screen is only drawn when 1/30 of a second actually passes, and it does not fully depend on the processor power. So if your CPU is in a heavy calculation, it will not freeze, but draw something still.
The limitations of this approach is often because the Begin Step and Step Events. If you have any sprite-changing or image-manipulating on those two events, it may get buggy but it really depends on your coding architecture.
Happy Delta Timing Drawing!
Edited by gmx0, 03 January 2012 - 01:59 AM.