Assignment3 Jump to bottom
Air Hockey Project
Objectives:
In this project, you will be starting your 2-Player Air Hockey project. Checkout the gamedescription and onine Air Hockey game to get familiarised with the game.You will be accomplishing the following items:Get familiarized with the basic structure of the Game.Process keyboard input from the user.
Add a player movement system.
Add a goal based scoring system.
Add an initial welcome screen, where you mention the scoring system and player controls.
Implement win-lose scenario.Display the scores and the winner of the game.Save the 10 best win scores in a file.
Setting up the goal area on the top and bottom boundary of the zone.Game Over ScreenIncrease the slider size from 4 to 7.Different speed of ball in different levels.Add obstacles for different levels.Add color to the game.
Game levels
Easy : Ball speed - lowest, Obstacles - NoneMedium : Ball speed - 20% increase from the Easy level, Obstacles - NoneHard : Ball speed - 20% increase from the Medium level, Obstacles - 2
Updating your repository: You will need to pull the updates related to the Air Hockeyproject from the course repository. You can do this using thefollowing git command
sequence.
git fetch
git pull upstream main
You should now have an air_hockey directory in your repository. Note sometimes your "main" is
called "master".
Create a assignment_3 branch: You will be creating a branch where you will be doing thework for this phase of the project. The AIs will refer to this branch to do the grading. Thefollowing are the steps for creating a branch. This involves creating the branch, checking itout, and then pushing the branch to your github repo. You can get more information onbranching in the Pro Git branching chapter.
git branch assignment_3
git checkout assignment_3
git push origin assignment_3
Don't forget that you have been working on the "master" or "main" branch so far. Think of eachbranch as an independent version of the code. If you decide to go back to main branch, just usecheckout command. By the way, you could decide to merge branches together but that's notwhat we will need for now.This branch should only be for your work on this project. For other course assignments, pleaseremember to switch back to your main branch using the following command.git checkout mainYou can check which branch you're currently in using the this command.git branch
File Descriptions
air_hockey.cpp: This file has the main infinite game loop. Before starting the game loop, all gamecomponents are initialized. The game has a sleep of 200 milli-seconds.ball.cpp: This file contains functions that check if the ball is colliding with the slider and the left &right walls of the zone. You need to write a similar function which checks if the ball is collidingwith the goal area in order to determine the winner.
slider.cpp: This file contains functions that initialize, move, draw and undraw the slider.
zone.cpp: This file contains functions to intialize, draw and undraw the zone.
key.cpp: This file contains the functionality to read user input from the keyboard while the gameis being played. You have to update this file and add cases for 's' and 'S' to save the state of thegame to a file.
Overview:
In this project we are going to be building a 2-player Air Hockey game on Khoury Linux server. Tosimplify the development of the game, we will be using the ncurses library rather than a pixelbased graphics library such as GTK. Ncurses is a character based graphics library that has beenused to develop command line utilities and tools such as editors.ncurses documentationTo get your project started, you have been provided with a template in the air_hockey folder.Below is a summary of the files that have been provided with the project.
Makefile: This file is used to build the executable air_hockey. The following is an example ofhow to build air_hockey.
$ make
g++ -c -o main.o main.cpp -I../include -g -O0
g++ -c -o slider.o slider.cpp -I../include -g -O0
g++ -c -o air_hockey.o air_hockey.cpp -I../include -g -O0
g++ -c -o zone.o zone.cpp -I../include -g -O0
g++ -c -o ball.o ball.cpp -I../include -g -O0
g++ -c -o key.o key.cpp -I../include -g -O0
g++ -o air_hockey main.o slider.o air_hockey.o zone.o ball.o key.o -I../include -g -O0 -ln
$
To remove the build files, you can do a "make clean". This will remove the executable and theassociate object files (*.o). This is useful prior to committing files to the repository because youtypically do not want to include generated files in the repo.
$ make clean
make clean
rm -f *~ core /*~
rm -f air-hockeyrm -f *.o
$
Building the Game
The game should be built following the below logical progression. You will start working onsmaller tasks that we call: 'get-to-know-the-code-base' before making bigger changes to thecodebase. Note: You do not need to submit different parts separately; please provide a single,
complete submission.
Part 1:
You should implement the code necessary to implement the following functionality.
Welcome screen
This is the starting screen in your game, on pressing t should start the game. On this screen,you have to provide an overview of the scoring system.
Moving the Players
Currently the slider (player) cannot move from the starting position, so you need to add playerontrols.he slider (player) should be able to move left, right, up and down.The arrow-keys should be used for moving the bottom slider around the zone in left, right,up and down directions.w,W, a/A, s/S and d/D keys should be used for moving the top slider around the zone in left,right, up and down directions.The slider may not cross the center line when striking the puck.The slider may only strike the puck when it is on its side of the centerline.The provided filename {key.cpp} file helps detect key presses.
Pausing the Game
The game is paused when P/p is pressed and resumes on another press.
Ending the Game
The game will end naturally when the time limit is reached (fixed to 2 minutes).Additionally, the game can be ended prematurely by pressing q or Q. In either case, thegame should terminate gracefully without causing a segmentation fault.Increase the slider size from 4 configurable up to 7.
Till Part 2, you see that the size of the slider is 4, now increase it upto 7.Prompt the user to input the size before the game starts.
Scoring the Game
Since it is a 2-player game only two mallets need to be placed on the AirHockey playingsurface.The puck needs to be struck with the mallet and the puck must fully drop in the goal area tobe counted as a goal. Rebounds or pucks that get stuck halfway in do not count as a point.Keep track of how much goals the users score.Print out a running score total at the top of the screen.
Game Over Screen:
The game over screen should be visible after the end of the game. *It should displayinformation such as points scored by both the players, winner and time taken to win.
Part 2:
You should implement the code necessary to implement the following functionality.
Implement win-lose scenario:
The game will consist of N rounds played in each level. The user should be able to enter thenumber of games N on the welcome screen.A player wins a set if they win the majority of the games in that set.The overall winner of the game will be the player who wins the majority of the levels
Save 10 best win scores:
*The information about 10 best scores should be stored in a file. Save them in
./saves/save_best_10.game Extensions don't matter in Unix, you'll be able to open the file at any
time in an editor.
Set up the goal area:
By default, the goal area is the entire top and bottom edge of the zone.If the player controlling the top slider is not able to defend the ball and it hits the top goalarea, then the opposite player scores a goal and vice-versa.In this step, you need to take the width of the goal area as an input from the user before thestart of the game. The width of the goal area should be less than the width of the zone.Different difficulty levels - Obstacles and Speeds The game starts with a ball that runs at a default low speed.As the player progresses through the levels, the speed of the ball should increase andobstacles should be added according to the Game levels description above.The obstacles can be placed at fixed positions or randomly within the game zone, but theymust not be placed on the walls.
Coloring the game
Add color to the game to make it more visually appealing. Use the ncurses library toimplement colors. Refer to the relevant section of the ncurses documentation for details onhow to use colors.
What to turn in.
Check your game into your assignment_3 branch. The TAs will checkout this branch, makethe code, and then run it to grade your work.Submit the link to the branch/commit similar to what you have done for other assignments.
Scoring (worth 135 points)
5 pts: Welcome screen (with Instructions to run)
10 pts: Move the first player with the arrow keys.
10 pts: Move the second player with the control keys.
15 pts: Keep track of the player's score.
10 pts: Speed of the ball with different difficulties levels.
3 pts: Press P/p to pause the game, must resume on another press
2 pts: Press Q/q at any time to quit the game.
5 pts: Set up the goal area
10 pts: Implement win-lose scenario.
15 pts: Save 10 best win scores.
5 pts: Game Over Screen.
5 pts Slider size change
20 pts Color the game
20 pts Add Obstructions in the game
Note: If your code does not compile and run on khoury server, your grade will start at 50%.
Please build and test in this environment.
标签:will,should,Project,slider,game,Hockey,branch,Air,pts From: https://www.cnblogs.com/qq99515681/p/18243191