One other thing that MAY be affecting it is that you're using a "Repeat"-"Until" loop, and main program loops are usually "While"-"Wend" loops
That's irrelevant. I've made loops using GOTO, and they work fine.Double-buffering (using the Flip command) requires you to redraw the entire screen every frame (Flip).
If you don't want to redraw the entire screen every frame, then
either don't use the Flip command (only draw to the front-buffer)
or
draw every change twice (draw commands / Flip / exact same draw commands).
But you'll usually find that the second option is just too annoying in most cases and you'll choose to either draw to the frontbuffer only, or redraw the entire screen every frame.