AggrorJorn Posted December 30, 2009 Share Posted December 30, 2009 I'm looking for a way to see wether I'm moving my mouse in the Y direction (forward and backward). if MouseDown(1)==1 then if MouseY = "Y moving forward" then do stuff if MouseY = "Y moving backwards" then do stuff end Any suggestions? Quote Link to comment Share on other sites More sharing options...
Niosop Posted December 30, 2009 Share Posted December 30, 2009 Look at any of the example games, like fpscontroller.lua. Usually they reset the mouse position to the center of the screen at the end of every Update. Then inside the update you can compare the current mouse position against the center position to see how much the mouse moved in any direction that frame. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Rick Posted December 30, 2009 Share Posted December 30, 2009 I wouldn't advise setting the mouse to the center of the screen however. I run duel monitors and I found that on one monitor GraphicsWidth()/2 gave a number with a decimal which screwed stuff up. Normally when in game mode (outside the editor) you don't run into this but for some reason inside the editor it's not always correct. The thing I realized last night is it doesn't really matter what you set the mouse position to as long as it's consistent. So I just set it to 200. If you don't require the mouse to be shown, you MoveMouse(200, 200) at startup once, then in your Update() you would first check mouse x & y minus 200 to get the difference in position, then MoveMouse(200, 200) to reset it. This will give you the difference that the person moved the mouse from the location 200,200. If it's positive or negative will tell you which way they moved it. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 30, 2009 Author Share Posted December 30, 2009 Now that I have a direction I can look into I can start puzzeling. I've created this sofar: before main loop: currentY = MouseY() main loop: centerY=(GraphicsHeight()/2) if (centerY >= currentY) then texty = 1 elseif (centerY <= currentY) then texty = 2 else texty = 0 end after the update: fw:Update() --get the current Mouse Y position currentY = MouseY() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.