Top-rated recipes by Dominic Innocent http://code.activestate.com/recipes/users/4178543/top/2011-07-18T15:11:51-07:00ActiveState Code RecipesBatting-ball (Python) 2011-07-18T15:11:51-07:00Dominic Innocenthttp://code.activestate.com/recipes/users/4178543/http://code.activestate.com/recipes/577799-batting-ball/ <p style="color: grey"> Python recipe 577799 by <a href="/recipes/users/4178543/">Dominic Innocent</a> (<a href="/recipes/tags/functions/">functions</a>, <a href="/recipes/tags/simple/">simple</a>). </p> <p>Have fun batting a ball about a room &amp; sometimes getting funny results.</p> Running 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>