Top-rated recipes tagged "vpython"http://code.activestate.com/recipes/tags/vpython/top/2011-07-17T16:50:01-07:00ActiveState Code RecipesRunning 2Balls in Vpython by Flip-Flopping. (Python) 2011-07-17T16:50:01-07:00Dominic Innocenthttp://code.activestate.com/recipes/users/4178543/http://code.activestate.com/recipes/577797-running-2balls-in-vpython-by-flip-flopping/ <p style="color: grey"> Python recipe 577797 by <a href="/recipes/users/4178543/">Dominic Innocent</a> (<a href="/recipes/tags/vpython/">vpython</a>). </p> <p>Getting Vpython to run 2 moving objects is tricky as it tends to focus on only one. The answer I have used is to 'Flip-Flop' between the 2 blocks of code running each object; Set up 2 values for the flip-flop K &amp; P. At the end of each nested 'While' P will be incramented (p=p+1). K is the remainder of P/2 (k=p%2). If k = 0 Flip! If k != 0 Flop!. I haven't got it to recognise a 'collision' event yet; &amp; that is very Frustrating!</p>