1. set up room with ghost sprite and object, put ghost in middle of room:
2. code keydown left event of objGhost:
4. to keep object from going outside the room, use Add Event → Other → Intersect Boundary to check if the object has hit the inside edge of the room:
both xprevious and yprevious are the last place the object was located. you can hit the 'plus' on the left to set 2 Instance Variables in 1 block.