How do I make this happen?

Is there a way for Processing to recognize which direction the mouse is traveling?  I want something different to happen when the mouse is pressed depending on the general direction it’s going.  I was thinking that maybe I had to make integers telling it, for example, if the only the mouseY coordinate is getting greater, to recognize that the mouse is traveling south.  I was looking at the distance function to see if that would help me, but I’m not sure.

Please let me know how I can do this.  Thanks!

-Nikki

Advertisements

~ by nmaller on March 2, 2008.

2 Responses to “How do I make this happen?”

  1. You are most of the way there in recognizing that you want to see if x or y values are increasing (or decreasing). All you need to do is create a variable ( say oldMouseY) and compare the VAR to the current mouse value. At the end of each draw update the variable’s value to the current mouse position (that way when draw gets called again the VAR has the old value from the last frame).

  2. Hi,

    There is also a built in variable for the mouse position in the previous frame (pmouseX and pmouseY). Check out book pg 208 for info. Distance, speed and orientation may also be useful (pg 238-244). I think it may be helpful to think through exactly what relationship you want to create between the user / mouse and the changing image. This will help you decide what you need to know (or infer) about the users actions. So, maybe you just need to do quadrants, and say if mouse x is > 50 and < 100, then…. Or maybe direction, angle or distance from a set point would tell you what you want to know?

    We will be going over some of this in class tomorrow, and we will also check in during lab time.

    Best,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: