Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP 308

Project

Pong

Due: April 28, 2023, on myCourses by 23:55

In this project, you will code the game Pong using the C Language, OpenGL and the x86 in-line assembly language. Your program will include an Intro Screen written in OpenGL and GLSL. You must work on this project on your own. This program consists of an intro screen and the game.

Even though the project is due April 28th, bonus points are given for completing the program earlier and for adding extra features. See the end of the project description to find out more about the bonus points. This project is graded out of 50 points. The bonus points cannot give you points above 50.

Pong (1972) was invented by Allan Alcorn2 and first released on the Atari computer. Pong inspired       many similar games like Breakout (1976, designed by Steve Wozniak1). Like other early arcade games, it only consisted of discrete logic components (no CPU). You can see a video of what the game Pong    looked like here:https://en.wikipedia.org/wiki/Pong#/media/File:Pong_Game_Test2.gif

Pong and then Breakout inspired many other games, most notably Space Invaders (1978, Intel 8080 assembly language) and Arkanoid (1986, Zilog Z80 assembly language). It also inspired the            development of the Apple II, as Wozniak wanted to be able to rewrite the game in software (Using  Integer BASIC).

This project comes with starter code. The starter code assumes you will program your project in the C Language and OpenGL using in-line assembler and GLSL. Alternatively, you can replace the in-line   assembler with regular assembler source files and link it with your OpenGL C code. If you chose this optional path, you must include in your submission the assembler source files, and more importantly, the assembler functions must match the template provided in the starter code.

You must build this project using the C Lion IDE. Your project can run on mimi or it can run locally   on your laptop. Please provide a redme.txt file to inform the TA how they should run your program.     Provide any additional instructions they might need. You must at least specify: runs on mimi / run on a mac / runs on windows. If there are additional configuration or installation instructions, make sure to   include that information.

Your program consists of an intro screen and then the game Pong.

Intro Screen

Your intro screen must be a variation (you can be creative) of the following: display two 3D paddles and one 3D ball. The paddles and ball must be GLSL shaded (not OpenGL shaded). For example, the ball could have the face of Sponge Bob, and the paddles could be glowing. In the background you     could have a skyline.

Display the name of the game, PONG, in big letters. You can stylize it if you want. The screen should

also say: “Press any key to continue” . When the user presses any key, the intro screen disappears, and the game starts.

The Game

Open the starter code and notice that some functions have already been programmed in OpenGL code. You should be able to compile and run the code to see something basic. However, the majority of        functions are empty with comments suggesting how you might populate it with code. These are hints  and suggestions to help you create the program. You are permitted to add helper functions. Notice  also comments suggesting how you might write your in-line assembly. Remember this is AT&T style of writing, so you write the assembler instructions in the opposite way you learned in MIPS and          INTEL.

Note: The intro screen is 3D, but the game is 2D.

The game displays like a traditional Pong game. Two examples are shown below.

 

Notice there is a playing field bounded by lines. The ball bounces off the playing field’s walls at a        constant speed. There are goals: one on the right and left (open spaces where there is no wall). If the    ball goes through the goal, then a point is awarded to the opposing player. The ball restarts after a goal by appearing in the center pitch moving at a constant speed towards the player who made the score. At the beginning of the game, the ball appears in the middle of the pitch and move in the direction of one of the players (use a random number generator to pick). Notice the score digits. These digits can be      within the playing field or outside the playing field. The ball is a circle. In the blue image the game      elongates the ball when it is moving very quickly (see the bonus). In our base game, the ball never       changes speed. The paddles are simple rectangles that move up or down. If the ball touches a paddle or wall, it bounces off at a constant speed (see bonus for other options). The game ends when one player  reaches 9 points. At the end of the game, the screen freezes and the message “End of Game! Press any key to end or r to restart.” is displayed in the middle of the screen. When the user presses any key, the  program terminates. If the player presses the r key the game restarts (not back to intro screen).

One player is an AI. The other player is the human. You are free to stylize things and provide more text on the screen to help the player understand what to do if you so choose. It is not a requirement. For full points you are only required to do the black and white Pong example above.

Code with Starter OpenGL

The following functions have OpenGL code already provided: main(), draw(), drawBall(),                    pixelToScreenX(), pixelToScreenY(), initGlobals(), and some global variables and data structures. You are permitted to modify or even replace these functions and data structures if you so choose. Running  the program as is will draw a circle on the screen.

Note: The functions that have OpenGL code provided does not imply that these functions are complete.

The functions that already have OpenGL code must be written in C and OpenGL. You are not permitted to add in-line assembly in these functions.

You must provide the functionality described in the comments for each function. These comments are the minimum you must do.

I would like to thank Allen Wei for providing this starter code.

Code with only Comments

The following functions are empty: drawPaddle(), drawScore, resetBall(), updateBall(), updateAI(), gameLogic(), mouse(), and keyboard(). You are permitted to add additional helper functions.

The functions drawPaddle() and drawScore() are in OpenGL. The functions mouse(), keyboard(),      updateBall(), resetBall(), updateAI(), and gameLogic() are all in-line assembly. You are not permitted to add C or OpenGL in these in-line assembler functions.

You must provide the functionality described in the comments for each function. These comments are the minimum you must do.

Bonus

I strongly suggest working on the base code before trying out the bonuses. Either build the entire base program and then refactor the code adding the bonus features or build the base framework (partly       completed) and once you are confident add a bonus feature.

If you are a strong programmer and feal comfortable using in-line and OpenGL, then starting with the bonus points is possible.

Please note that one of the bonus points is about submitting early, anyone can plan for that.

This project is worth 50 points. Receiving bonus points cannot increase your grade above 50.

Bonus features:

•   +2 points: Update the intro screen by replacing the press any key to continue” feature with a   button that says, “Start Game” . The user must move their mouse above the button and press the left mouse button to start the game. You do not need to animate the button press.

•   +2 points: Convert the game elements to 3D: 3D ball and 3D paddle, but the ball still moves in a 2D space.

•   +2 points: Ball’s speed changes when bouncing off a paddle that is moving quickly. The speed  of the paddle transfer to the ball proportionally increasing the balls speed after bouncing. You   must track paddle speed and ball speed. The player can also slow the ball by moving the paddle is the opposite direction of the ball, transferring the paddle’s speed to the ball in the negative     direction. You must implement a max and min speed where the ball cannot pass so that the        game never becomes unplayable.

•   +2 points: Elongate the ball into a line proportional to its speed (or multiple overlapping balls) when moving quickly. The “leading” edge is the ball.

•   Submitting the project early!! 5 days early +5. 4 Days +4, 3 days +3, 2 days +2, 1 day +1.

WHAT TO HAND IN

1.   Make sure to comment all your source file with your student name and ID number. For example, add before the Allen Wei information in the template with your information.

2.   The edited ProjectStarterTemplate.c file that runs on the C Lion IDE.

3.   Any helper .c files you included in the project.

4.   If you chose to replace the in-line assembly for regular INTEL assembler code, then provide    those assembler source files. Remember that these source file must still implement the function signatures described in the template as specified. You can provide additional helper functions. This must compile and run on the C Lion IDE.

5.   Please also provide any image assets.

6.   The readme.txt file which explains how to compile and run your program and tells the TA your runtime environment (mimi, local mac, or local windows).

7.   Provide libraries or instructions to obtain the libraries not covered in class. Write this in the readme file.

8.   ZIP all the files in their correct directory locations and C Lion project file into a single ZIP file called 308Project.zip.

HOW IT WILL BE GRADED

The project is worth 50 points. The TA may award partial credit. You cannot receive more than 50 points (even with bonus points).

Points deducted:

•   - 10 points for not following instructions.

•   Two late day penalty (5% per day)

Points awarded:

•   3D intro screen          .

•   Pitch layout and look .

•   Goal mechanics: ball disapears and ball drop mid pitch      .

•   Incrementing and display of points   .           .           .           .

•   Ball’s look and motion          .           .           .           .           .

•   Paddles looks and motion      .           .           .           .           .

•   Bouncing off walls and paddles constant speed       .           .

•   The “AI” player         .           .           .           .           .           .

•   End of game screen with reset and quit        .           .           .