By using GUI (GUIDE is more convenient) in matlab create a basketball shooting g
ID: 3852397 • Letter: B
Question
By using GUI (GUIDE is more convenient) in matlab create a basketball shooting game
And it is better if you can offer some choices for the users,such as the size of the basket,the distance between the man and the basket. hint:the most simple way is: at first,the game ask the user to input the angle and the velocity, and then the game will illustrate a parabola and determine if the ball enter the basket or not.
I already have the following:
function parabola()
fprintf ('WELCOME TO THE GAME ');
fprintf ('Choose distance of the basket: ');
fprintf ('1. 25m 2. 40m ');
distance = input('Enter 1 or 2: ');
u = input('Enter the initial velocity of the basketball: ');
a = input('Enter the angle at which you want to shoot: ');
% calculate the range
R = (u*u)*sin(2*a);
R = R/9.8;
if (R == distance)
fprintf (' You have won!');
else
fprintf (' Sorry, better luck next time.');
end
end
OUTPUT:
I would like to edit the code to add the parabola that shows whether the ball goes in or not.
Explanation / Answer
Answer for the given Question:
Once the basket ball thrown it will reach to the basket by parabola path, so you calclated the distance between basket ball point to basket, so we got the distance and then you compared, this is right only.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.