Can someone make the pong game on MATLAB with a counter, timer, and score limit
ID: 3733855 • Letter: C
Question
Can someone make the pong game on MATLAB with a counter, timer, and score limit using these pictures. Also 1.One player controls the right paddle with the uparrow and downarrow keys. The other player controls the left paddle with the ‘w’ and ‘s’ keys. The paddles can only move up and down.2.The ball starts at the center with motion in a random direction. The ball bounces off the walls and paddles such that the velocityin the direction normal to the surface reverses.3.If the ball hits the wall behind eitherplayer, his/her opponent scores a point and theball starts in the center again.Some optional things to consider:1.Prevent the paddles from moving off the screen. 2.Display the scores using the uicontrol()function to create text boxes. 3.Have the program quit gracefully either with a quit button or by pressing ‘q’.
Explanation / Answer
Code to copy with explanation:
#include <iostream.h> // input output stream header file
#include <stdio.h> // standard input output header file
#include <stdlib.h> // standard library header file
//#include <string.h> // header file with string function
// #include <conio.h> // console input output header file
#include <time.h>
class player {
char *name;
int openNumbers[9];
int closedNumbers[9];
char *result; // win, withdraw
int numThrown; // between 1 to 12
int numOfDiesThrowable; // 1 or 2
};
class boxes {
int boxNumber;
char boxPosition[10]; // open or shut
};
int totalAttemptCount = 700; // maximum number of attempts possible in the game
int main() // start main
{
srand(time(NULL));
int count=0, n, seed; // i,j,k : l,m,n
int l,m,n, Die[36];
int i,j,k;
for (count=0; count <= totalAttemptCount ; count++) {
int numRolled = rand()%6;
for (m = 0; m<= 6; m++) {
seed = 1;
srand(seed);
numRolled = rand()%6;
Die[m] = numRolled;
} // end inner for
int flipCount = 6, total = 0;
for (l=1; l<= flipCount; l++) {
total = total + Die[l];
} // end for
} // end outer for
return 0; // exit
} // end of main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.