Well, can't help you with the coding part but here's the spriting:
So, the pink/magenta/purple borders are fillings to seperate the frames, it's not needed but if anything is drawn where where they are supposed to be then it won't show up as the final result.
The frames indicated different...