I’m going to strike the cue ball with a center-ball hit $(a=0, b=0)$ straight down the table $(\phi=90)$ with the cue completely level with the table $(\theta = 0)$. ![]() This method ultimately calls upon physics.cue_strike, which implements the cue-ball interaction physics described here. How much vertical english should be put on? -1 being bottom-most side of ball, 1 beingįile: ~/Software/pooltool_testing/psim/engine.py How much side english should be put on? -1 being rightmost side of ball, 1 being How elevated is the cue from the playing surface, in degrees? ![]() The direction you strike the ball in relation to the bottom rail What initial velocity does the cue strike the ball? strike ( ball, V0, phi, theta, a, b ) Docstring : """ Though the codebase has changed dramatically since this original implementation, this central design principle has remained unchanged. This separation of responsibility allows different physics models to be plugged in or out at will. With this in mind, engine.py implements the shot evolution algorithm by coordinating when object states should be modified, and physics.py implements the physics that provides the specific rules for how the modification should be carried out. The rationale for this design was to separate the physics from the objects that the physics acts on (balls, cues, cushions, etc). This project started with 2 main modules: engine.py and physics.py. With this all now behind me, it’s time to take this theory to the streets. After a second click, the program ends.In the first and second posts of this series, I discussed ad nauseam the physics and algorithmic theory behind pool simulation. # The ball must start moving after a click, then stop after a given Specific problems with your code: makeBall() fails to return balls makeBall() needs to generate random starting points, not all starting at the same place bounceInWin() needs to have a separate, and separately updated, dx and dy for every ball, not just the one the code creates the main window twice - just once is fine need to add time calculation to shut down motion instead of fixed number of iterations win.close() is a method so it needs parentheses avoid using semi-colon " " in Python code.īelow is a rework of your code with the above changes and some style tweaks: # Create 10 balls bouncing off all 4 sides of a window (400 x 500) Win.getMouse() #close doesn't work, tried putting in loop #animate 10 balls bouncing off edges of windowĭef bounceInWin(shape, dx, dy, xLow, xHigh, yLow, yHigh):ĭef getRandomPoint(xLow, xHigh, yLow, yHigh):Ĭenter = getRandomPoint(xLow, xHigh, yLow, yHigh)īounceInWin(ball, dx, dy, xLow, xHigh, yLow, yHigh) Win = GraphWin('Ball Bounce', winWidth, winHeight) #all 10 balls move in different directions bouncing off all 4 walls #create array of 10 circles in different starting points ![]() #The ball must start moving after a click, then stop after a given amount of time I'll post what I have so far below: #create 10 balls bouncing off all 4 sides of the window (400 x 500) ![]() I'm still very new to this and confused on how to implement this. I have a program in Python for making one ball bounce off of all 4 sides of a window, but now I need to make 10 balls using an array.
0 Comments
Leave a Reply. |