A concept for a game I will be making shortly, this uses mouse coordinates to make a "box" the circle cannot escape. It takes a bit of time to make a shape other than a box or a rectangle, but it is possible. Press space to put the pen down, so you can visualize the "box". If you move the mouse very quickly, the circle might go a few pixels out of line, but it will be corrected very rapidly. Also, if you move the mouse too quickly, the ball will become stuck at whatever x or y position it was at when the mouse was removed from the box.