Question
The Cannonball simulation we developed together in class is attached to this week's notes. Study it carefully to understand exactly what it is doing. It
The Cannonball 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.
1) Add a new class named "Cannon". This class it to represent the cannon that launches the balls. It should draw a rectangle the launch point. Its width should be equal to the diameter of the balls that it shoots out and its length should be 2 times the diameter. The cannon should also be directed in the same direction that the balls it shoots. Adds 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 a dialog 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 will be possible to select how small or large the ball will be.
3) Modify the simulation so that the input dialog stays on the whole time and does not close during the ball flight. Of course it should not cover the path, so try to locate it somewhere on the top left or right of the drawing area of the flight path.
4) Add a Target class to the cannonball animation. A target should be a rectangle placed at a random x position at the bottom of the window. Allow users to keep firing until they hit the target.
Link to base code ==> file:///C:/Users/17785/Desktop/Week%2010%20notes-20200710/week10_2/week10_2/ProjectileSimulator.py
Step by Step Solution
3.56 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
from math import pi sin cos radians from graphics import from inputDialoge import comment in show up when printProjectiledoc class Cannon def initself ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started