Spade wrote:How would I go about fixing the lag?
The difference you see between the system cursor and your drawn cursor probably comes from vertical synchronization.
If vsync is enabled, the graphics card will not send the next frame until the monitor has fully drawn the last one. This means the framerate gets limited to the refresh rate of the monitor, which is usually 60 frames per second.
With 60 fps, one frame is displayed every ~16 ms. There is a chance that the execution stops for 16 ms, if the code is fast enough.
What it coud look like:
Code: Select all
Time in seconds called function
------------------------------------------
0.0000 love.update
0.0001 love.draw
0.0171 love.present
0.0172 love.update
0.0173 love.draw
0.0355 love.present
0.0356 love.update
0.0357 love.draw
...
The screen shows an image that was generated ~16 ms earlier in this case.
You can try to move the waiting before the update by writing your own
love.run() and approximating the time it has to sleep for 60 fps, but this is inaccurate and can give problems once the game gets more complex.
Or you can disable vsync with
love.graphics.setMode(). Remember that screen tearing and much higher frame rates are effects of disabling it. (LÖVE caps to 1000 fps by sleeping 1 ms in love.run)
Shallow indentations.