Jump to content

Checking if mouseY is moving


Recommended Posts

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.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:

		if (centerY >= currentY) then 
			texty = 1
		elseif (centerY <= currentY) then 
			texty = 2
			texty = 0			end


after the update:


--get the current Mouse Y position	
currentY = MouseY()

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...