The best is to use the canvas instead of a graphics buffer. Open a graphics mode and a window and a canvas on top.
The game loop also should be inside the timer tick($4001) Create a timer for this.
The game loop also should be inside the timer tick($4001) Create a timer for this.