We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Help: location mouse stored per frame
Page Index Toggle Pages: 1
Help: location mouse stored per frame (Read 301 times)
Help: location mouse stored per frame
May 22nd, 2008, 6:21pm
 
Hello programmers,

I don't have much experience with programming, but I'm learning...

I'd like to know how the x en y positions of the mouse are stored in an array PER FRAME. When a user drags the mouse, the x and y coordinates are stored and when the mouse is released, the program draws little circles at the stored positions. This way the user sees the locations of the mouse afterwards per frame. So how do I store this information and how can I retrieve it?

I've spent some hours on this puzzle, but for more experienced programmers it's probably simple...

Your help would be very much appreciated, especially with clues about the code!

Thanks a lot!
Re: Help: location mouse stored per frame
Reply #1 - May 22nd, 2008, 6:40pm
 
I would use Java's ArrayList to store Point objects, Point being a simple class with x and y members and a simple constructor setting these.
On each draw() call, I would do arrayList.add(new Point(mouseX, mouseY)).
Then on mouseReleased you draw your circles and clear the list.
Page Index Toggle Pages: 1