User Tools

Site Tools


notes:cprog:spring2025:projects:mtb2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:cprog:spring2025:projects:mtb2 [2025/02/25 03:48] – [score display] tstricklnotes:cprog:spring2025:projects:mtb2 [2025/02/25 22:07] (current) – [score display] bdildine
Line 24: Line 24:
 ====score display==== ====score display====
 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. 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.
 ====computer operated player==== ====computer operated player====
 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. 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)
 ====determining computer paddle movement==== ====determining computer paddle movement====
 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. 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.
 ====difficulty of computer player==== ====difficulty of computer player====
 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}. 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}.
notes/cprog/spring2025/projects/mtb2.1740455289.txt.gz · Last modified: 2025/02/25 03:48 by tstrickl