Currently, that function redraws the background every world x/y change up to 60 times a second. Takes up a lot of time to do so when the world is panned. On older computers and tablets, the fps is reduced.
Instead, we could increase the background canvas by a buffer (say 2 tiles larger and taller). When the world x/y changes slightly, we will not need to redraw - but instead just perform a copy of the panned region.
For Super Mario, I estimate this strategy would cause a redraw only once per second instead of 60.
Currently, that function redraws the background every world x/y change up to 60 times a second. Takes up a lot of time to do so when the world is panned. On older computers and tablets, the fps is reduced.
Instead, we could increase the background canvas by a buffer (say 2 tiles larger and taller). When the world x/y changes slightly, we will not need to redraw - but instead just perform a copy of the panned region.
For Super Mario, I estimate this strategy would cause a redraw only once per second instead of 60.