I made a level editor, but you can see most of the code in it (:
https://scratch.mit.edu/projects/517347957/