Question: This task is based on your completed work in Credit Task 1 (question 2) and Distinction Task 1. You will design a game interface in

This task is based on your completed work in Credit Task 1 (question 2) and Distinction Task 1. You will design a game interface in a MATLAB program named HDTask1.m. In this game, an animation should be created to display the flying trajectories of the ball shot from a fixed initial height and fixed initial velocity at release. The game player will attempt to adjust the release angle (shooting angle) of the ball to hit a board placed at the ground. Once the ball hits the board, the player will score one point. Then, the board will be randomly re-located to another position for the player to attempt another round. The specific design requirements are given below:

Initial height of ball at release is fixed at 1.5 m.

Initial velocity of ball at release is fixed at 4 m/s.

Board length is of 0.5 m and located at height 0 horizontally.

Diameter of ball is approximately one-third of the board length.

The ball should be at rest on the board for at least 0.5 second once hit.

The board should be randomly re-located within a range reachable by the ball for each new round.

Scores should be displayed.

The player could adjust the shooting angle in command window and command the action of shooting.

The program should have a command for player to exit the program.

The program should handle exceptions such as when player enters an invalid shooting angle, etc.

The program should not crash MATLAB during running (i.e., good reliability).

You may add additional functions to your program to make it funny.

Show the screenshot of your game interface and the animation snapshots. You should add comments in your program to describe the codes allowing others to understand your code easily. Screenshots of the game may look this:

Hint: Study the following script code on how to create animation in MATLAB. %Define variables: % h1 -- Handle of line % a -- Amplitude of sine function at an instant % x -- Independent variable % y -- a * cos(t) * sin(x) % Calculate the times at which to plot the sine function t = 0:0.1:10; % Calculate sine(x) for the first time a = cos(t(1)); x = -3*pi:pi/10:3*pi; y = a * sin(x); % Plot the function. figure(1); hndl = plot(x,y); xlabel('x'); ylabel('Amp'); title(['Sine Wave Animation at t = ' num2str(t(1),'%5.2f')]); % Set the size of the y axes set(gca,'YLim',[-1 1]); % Now do the animation for ii = 2:length(t) % Pause for a moment drawnow; %pause(0.1); % can be uncommented if updating is too fast % Calculate sine(x) for the new time a = cos(t(ii)); y = a * sin(x); % Update the line set(hndl, 'YData', y); % Update the title title(['Sine Wave Animation at t=' num2str(t(ii),'%5.2f')]); end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!