Maybe this line?
if (y < 20 || y >= 580)
I just write a prototype quick (of a new feature, new game whatever), if it works, I then refactor messes of code starting with the most messy and critical. If it doesn't, then I throw away the feature (like start a new project or remove the files away and let them stay only in git history). The refactor/throwaway approach also applies to code I didn't write (engine, lib, addon class, etc): if I use the code, it's now my code.
The "I will write a feature-rich general-purpose game engine first, and then will make games with it" mindset is self-deception. The goal is not making an engine, the engine is just a tool (including the wrapper systems you write).
It is important to clearly state what is your current (mini-)goal. Like - to make a build for playtesting with all core mechanics working, to add enemy behaviour, to make managing new assets faster, etc. And if, for example, you already manage assets kind of fast (takes tiny percent of development time) - just don't bother about it.
Hope this helps :-)
I think you want pixel perfect collision, otherwise, the collision is based on bounding boxes. Like FlxG.pixelPerfectOverlap(), don't know if there is one built-in for collsions.
I never used flipped tiles, but you should read the gid as hex value, with high bits meaning the flipping type - horizontal, vertical and diagonal. Diagonal is 90 degree rotation (combined with horizontal and vertical you also get 180 and 270)
acceleration.y to gravity value. And
velocity.y to projections of velocities on axes. To calculate those projections you can use