Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cica!iuvax!bsu-cs!mithomas From: mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) Newsgroups: comp.sys.mac.programmer Subject: Re: How do you set the mouse position? Message-ID: <10829@bsu-cs.bsu.edu> Date: 26 Feb 90 19:32:06 GMT References: <4081@hub.UUCP> Reply-To: mithomas@bsu-cs.UUCP (Michael Thomas Niehaus) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 26 If you are writing a game, there is no reason to move the mouse. Just hide the real cursor and have your program put up a fake one that will stay inside the game window (it can even look like the real one if you like). I used this approach in a game that I wrote where I wanted to restrict the movement of the mouse to a two-dimensional path, and it worked quite well. (Actually, I later modified the game so that the real cursor turned into a cross-hair, and the fake cursor just mirrored the real cursor's movements in a horizontal-only manner.) If you want easy to implement, just use the normal local coordinates. If they are outside of the visible region of the window, set the fake cursor to the boundary position. If you want a better feel, register the change in the mouse position (delta) and move your fake pointer by those amounts. (This is better when the real cursor leaves the window area. When you return, the fake pointer will move even though the real pointer is not yet back in the window.) You can even do your own scaling here (if for some reason you really wanted to). -Michael -- Michael Niehaus UUCP: !{iuvax,pur-ee}!bsu-cs!mithomas Apple Student Rep ARPA: mithomas@bsu-cs.bsu.edu Ball State University AppleLink: ST0374 (from UUCP: st0374@applelink.apple.com)