Topic: Game Programming /
The problem you will have with that, is the user can keep dragging the mouse and when the pointer is clear of the wall on the other side, the object will jump straight through it.
Probably the solution you need (to make walls completely solid and impassable) is to test several positions between where the object was last frame and where the mouse is this frame… if the positions all overlap each other then you will get the solid reaction you need from the wall.
As far as I know there is no way to move the actual mouse location back to where your object is stuck… although I’ll be interested if anyone can suggest one! You could of course add your own graphic for a mouse pointer and move that where-ever you want, but then you’ll find the position of your mouse pointer will differ from the actual mouse pointer and that will cause problems when it leaves your game window.