Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Better Understanding of "MouseMove"

Author
Message
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Feb 2014 17:56
I'm having one of those extra-dumb days where simple things don't work for me. Could someone explain why this would return zero?



Can someone provide a snippet that shows how to get definite values out of mousemovex() and mousemovey()?

I've searched the forums but to no avail.
Seems like I already mastered this command before, now I just feel dumb.


Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Feb 2014 18:16
They are delta values between each call to the function (ie. mouseMoveY() returns the distance the mouse cursor has moved along the Y axis since the last call to mouseMoveY().

To maintain the value on a per-frame basis, like I'm assuming you want, you simply store the results to variables at the top of your main loop and then use those variables as needed further down in the loop.

Basically calling those functions resets the value back to 0 and returns what it had previously stored.


"Why do programmers get Halloween and Christmas mixed up?"
pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Feb 2014 18:29
Try


windowsXp
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Feb 2014 19:20
Thanks pcRaider!

Although I'm curious, I'm not even going to ask why it works that way and not the other!

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Feb 2014 19:44
Quote: "Text"

|
v
Quote: "Although I'm curious, I'm not even going to ask why it works that way and not the other!"


...


"Why do programmers get Halloween and Christmas mixed up?"
zeroSlave
14
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 19th Feb 2014 05:29 Edited at: 19th Feb 2014 05:32
When you call the mousemovex() function, it returns the amount of movement since the last mousemovex() call (or sync update). In your above code, you called it twice on the same line. There would not be any difference between the mouse's position after the last time it was called.

A simple example of a return function being called twice:


Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 19th Feb 2014 16:37
Quote: "When you call the mousemovex() function, it returns the amount of movement since the last mousemovex() call (or sync update)"



Ahh... makes sense now!
I didn't realize that calling it would also reset it.

Thanks zeroSlave!

Login to post a reply

Server time is: 2024-03-28 23:46:29
Your offset time is: 2024-03-28 23:46:29