use Pyhton.
The tossball simulation we developed together in class is attached to this week's notes. Study it carefully to understand exactly what it is doing. It currently launches a ball in the main graphics window. You need to make the following changes and improvements and send me at the end your finished project in zipped folder format. Only python modules should be included.
1) Add a new class named "Cannon". This class it to represent the cannon that launches the balls. It should draw a rectangle (hint: use Polygon class from Graphics.py) at the launch point. Its width should be equal to the diameter of the balls that it shoots out and its length should be proportional to the speed, say something like speed * 0.15. The cannon should also be directed in the same direction that the balls shooting. Add proper width, height, and angle attributes to the class for supporting the settings above. The balls should start from the bottom of the cannon and be projected out through the cannon pipe.
2) Add an input field to InputDialog to allow for choosing the radius of the ball. Currently the ball radius is set to 3. By this change you make it possible to select how small or large the ball will be.
3) Modify the simulation so that the flight track of the ball is drawn to the screen as the ball flies through its path. The track should disappear after ball hits the ground or goes out of screen.
4) Add a Target bar to the x axis. A target should be a thin rectangle placed at a random x position. Its width should be twice as large as the radius of the ball. Any time the ball hits the target a text should show up in the middle of screen saying "SUCCESS! Hurry!". THe text should disappear as soon as user shoots next ball.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here