Corning Community College
CSCS1320 C/C++ Programming
Complete your pong game. Have it functional for two players (one or both may be computer controlled), and keep/display a score.
You will want to go here to edit and fill in the various sections of the document:
NOTE: this is a collaborative document between a couple of my classes this semester. That means more people editing. Be mindful that only one person can edit the document at a time.
Only task headings have been provided. You are not expected to know how to do the task given by just that description (although in some cases it can be adequately figured out). Instead, if no further information is yet present, ASK FOR DETAILS on the discord, then contribute that clarity here.
If something is present but needs polish: spruce it up.
If something is present but is incorrect: please fix it.
This is intended to be an informative, useful document that all can benefit from.
Those with prior experience, please be mindful not to gobble up all the low-hanging fruit from the newcomers.
To enable scoring, Variables need to be declared to in order to keep track off, and allow for later use.
Make two integers to represent Player 1 and Player 2's scores. Every time that the ball hits the sides, determine who gets the point, and add that to the respective variable of the player who scored.
Within the video.h header file, there is a series of print functions, which prints characters to the screen based on the string that is provided to it. You can use the itoa(); function included in the string.h header file to convert your score from and integer to a string if that's the method you are using.
To allow for the paddle to track the ball, it would be recommended to find a linear equation to represent the balls path, that which changes everytime it bounces of the roof, floor, or paddle. After finding the y-intercept, x-intercept, and slope of the ball's particular direction, It is now possible for the paddle to predict where the ball will be. This is done by plugging in the paddle's x position into the equation, thus returning the y coordinate output that the ball will be at when on the domain of the paddle.
note: slope intercept form y = m(x - x1) + y1
y1 = y-intercept. x = desired x location to return the projected y position of the ball. (AI paddle's x position)
Now that equations are set up to represent the movement of the ball every time it switches directions, just make the paddle move up or down based on whether it is less than or greater that the predicted y coordinate of the ball while on the x coordinate of the paddle.
an integer can be made to represent the difficulty of the player. The difficulty can control how fast the player moves or maybe how accurate it is. This example will only make it move faster. After making the integer to represent difficulty, one could make either a switch statement, or if statements to change the speed at which the paddle moves based on the condition of difficulty. eg. if(difficulty == 1) { paddleSpeed = 2}.
To be successful in this project, the following criteria (or their equivalent) must be met:
Let's say you have completed work on the project, and are ready to submit, you would do the following:
lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
I'll be evaluating the project based on the following criteria:
130:mtb2:final tally of results (130/130) *:mtb2:submitted Vircon32 cartridge [13/13] *:mtb2:submitted C code XML and build script [13/13] *:mtb2:fully working pong game [13/13] *:mtb2:display of scores on the screen [13/13] *:mtb2:cartridge is NOT added to repository [13/13] *:mtb2:bounds checking for paddle and ball [13/13] *:mtb2:initial collision detection for ball and paddle [13/13] *:mtb2:committed project related changes to semester repo [13/13] *:mtb2:screenshot or video to class discord channel [26/26]