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 & HelpPrograms › Question regarding ‘Bounce’ example (dictating mov
Page Index Toggle Pages: 1
Question regarding ‘Bounce’ example (dictating mov (Read 304 times)
Question regarding ‘Bounce’ example (dictating mov
Jul 25th, 2006, 8:13pm
 
I’ve been playing around with the movement examples and I’m having a difficult time dictating movement.

0115 isn’t allowing me to copy and paste code from ‘Format for Discourse’ so use ‘Bounce’ from the Examples folder as reference.

Ideally I’d like the program to tell the object to move in the direction of which directional key is pressed. For instance if the ball is going towards the right the left key will reverse the direction and the object will start going towards the left. If the up key is pressed the object will start going up.

I figure to make it work the program will have to determine the object’s trajectory and that’ll dictate what is up, left, down, and right. For instance if the object is heading ‘left’ at 270 degrees right will tell it to reverse its trajectory towards 90 degrees, up 0 or 360 degrees, and down 180 degrees.

That’s where I’m stuck. How does one gauge in what direction the object is moving? Once calculated, how would I tell the program to determine what’s the opposite of the direction?

Thanks

Allen
Page Index Toggle Pages: 1