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 › Control / Control Loss  Urgent!!!
Page Index Toggle Pages: 1
Control / Control Loss  Urgent!!! (Read 363 times)
Control / Control Loss  Urgent!!!
May 14th, 2008, 9:45pm
 
Hi there!

I'm developing a project but I'm having some problems with the code (I'm a newbie using processing)

The project is an user interaction object, the user controls /manipulates something, with the computer mouse, he can see the reflex of his actions on the screen: until this point everything is OK (I know how to do this).

But, I intend for the user to loose that control at some point, meaning: the "machines" takes over, it acts on its own for a while and then returns the control back too the user.

I would like too know if somone could help me with this, how can I do it, or if there are projects that use simillar code?  

Its for an Universisty project...so I'm really short on time!!

Thanks in advance!
Re: Control / Control Loss  Urgent!!!
Reply #1 - May 15th, 2008, 2:31am
 
You're going to want to look up the Robot class (http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html) and read those docs.  I really hope you have ultimate control over the systems this needs to run on, otherwise you're going to have a lot of headaches getting the security issues worked out...

I've never personally used Robot for anything, maybe someone that has can give you more specific advice?
Re: Control / Control Loss  Urgent!!!
Reply #2 - May 15th, 2008, 8:09pm
 
You can use, for example frameCount (or a time counter) to know when to take control and when to release it.
For example, I took the Reach2 demo, and added/changed the following lines:
 int mx = mouseX, my = mouseY;
 if (frameCount > 500 && frameCount < 700) { mx += random(-100, 100); my += random(-100, 100); }
 reachSegment(0, mx, my);
(last line it the original one I changed)
After a while, it acts erratically (but can have more sophisticated moves), then behave normally.
Re: Control / Control Loss  Urgent!!!
Reply #3 - May 15th, 2008, 8:16pm
 
Oh thanks! Wink

I'm gonna try that!, I had already thought if I could use time or frames for this.

And I actually want it to be kind of erratic, so it suits my purposes. Cheesy
Page Index Toggle Pages: 1