Credits to @griffpatch's scrolling platformer tutorial for learning me how to make a scrolling engine. This is a version of griffpatch's engine that is modified a little by me.
I've tried to explain how this engine works with comments inside, but for a more detailed tutorial, watch griffpatch's tutorial on youtube Questions? Comment them :)