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 / Mouse and box don't move together

Author
Message
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 6th Aug 2004 03:01
Hi.

I was running through Joseph Thomsons tutorial and was working on mouse input. The code below shows what I've got so far but when I run it the mouse and the box don't move around at the same pace. the mouse is much faster than thte box

Is there any simple way of solving this,



Thanks in advance.
Calculus
20
Years of Service
User Offline
Joined: 22nd Feb 2004
Location: Earth
Posted: 6th Aug 2004 07:16
If you add an extra variable called clicked then the mouse will not drop the box unless you release the left mouse button again. Hope this helps!



Kind Regards
Calculus
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 6th Aug 2004 18:34
Thanks Calculus. This makes the code easyer to handle. though the mouse still seems to move faster than the box.

If I click on the box and move the mouse left to right by the time I have moved to the far right or far left of the screen the mouse cursor has moved so fast it is now out of te box.

is there anything I can do to stop this?
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 6th Aug 2004 19:19 Edited at: 6th Aug 2004 19:21
I believe you'll find that's from the dual reading of the mouse position and then the mouse movement values, over and over as the loop proceeds and takes time away. Ie; if mouse is x=9 and move to x=10, then mousemovex() returns a 1. Then the loop "hops" now & then over the next pixel from say 10 to 11, as DB is computing the other values and pasting the box, while the mouse is still moving. Then you get another read, another movement change, another hop, etc.

I personally have had trouble using the mousemove commands myself so am not certain how to advise you right now, but I'll be watching!
S.

Any truly great code should be indisguishable from magic.
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 9th Aug 2004 20:46
Now I understand. Looks like it needs sume sort of work around.

Could this be considered a bug. clicking on things and moving them round could be very useful in some sorts of games. I notice this problem doesn't arise with the keyboard as there is a buffer that remembers everything. Can not something similar be created for the mouse.

If I work out a workaround I'll post it up but not untill next week as I'm away for a while.

If anyone can give guidence on the easiest way to aproach this problem it would be much appreciated.

JC.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Aug 2004 22:31
You should use either the mousex/mousey, or the mousemovex/mousemovey but not both as they don't always give the same measurements.

You also have a slight problem with the sequence that you are processing in - you always display what happened in the last frame, not the current frame.

Try this code instead



Watch out for typos - I manually copied this across.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Jac
20
Years of Service
User Offline
Joined: 9th Nov 2003
Location:
Posted: 13th Aug 2004 03:44
thanks IanM.

That works great. I even sat down and worked out what happening with your code and learned a couple of things.

Much Appreciated.

JC
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Aug 2004 05:30
You're welcome

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-09-22 20:28:48
Your offset time is: 2024-09-22 20:28:48