Here is a platform engine made by SullyBully, and commented by myself. Arrow keys to move hitbox1. (Code by SullyBully, commented by myself.) W-A-D keys to move hitbox 2. (Original code by SullyBully, modified by myself.) Remix how ever much you want.
Credits to SullyBully for this awesome example of an elegant, straightforward, well done platforming movement and collision system. I've gone through hitbox 1 and commented much of the code to explain exactly what each part and line does. I also duplicated, then modified, hitbox 1 to create hitbox 2, in my attempt to see if I can further streamline, or at the very least offer an alternative, to the wonderful code provided by SullyBully. In the end, I was able to reduce the code by a few lines while only minimally affecting behavior (difference can be seen when hitting ceiling), and I also renamed variables and functions for greater clarity.