首页 > > 详细

讲解 program、辅导 C++编程设计

Assignment3
Jump to bottom
nishithamadhu100 edited this page 3 weeks ago · 30 revisions
Air Hockey Project
Objectives:
In this project, you will be starting your 2-Player Air Hockey project. Checkout the game
description 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 Screen
Increase 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 - None
Medium : Ball speed - 20% increase from the Easy level, Obstacles - None
Hard : Ball speed - 20% increase from the Medium level, Obstacles - 2
neu-cpp /
Summer-2024
Code Issues Pull requests Projects Wiki Security InsightsPreliminary Steps
Updating your repository: You will need to pull the updates related to the Air Hockey
project from the course repository. You can do this using the following git command
sequence.
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 the
work for this phase of the project. The AIs will refer to this branch to do the grading. The
following are the steps for creating a branch. This involves creating the branch, checking it
out, and then pushing the branch to your github repo. You can get more information on
branching in the Pro Git branching chapter.
Don't forget that you have been working on the "master" or "main" branch so far. Think of each
branch as an independent version of the code. If you decide to go back to main branch, just use
checkout command. By the way, you could decide to merge branches together but that's not
what we will need for now.
This branch should only be for your work on this project. For other course assignments, please
remember to switch back to your main branch using the following command.
You can check which branch you're currently in using the this command.
File Descriptions
air_hockey.cpp: This file has the main infinite game loop. Before starting the game loop, all game
components are initialized. The game has a sleep of 200 milli-seconds.
git fetch
git pull upstream main
git branch assignment_3
git checkout assignment_3
git push origin assignment_3
git checkout main
git branchball.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 colliding
with 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 game
is being played. You have to update this file and add cases for 's' and 'S' to save the state of the
game to a file.
Overview:
In this project we are going to be building a 2-player Air Hockey game on Khoury Linux server. To
simplify the development of the game, we will be using the ncurses library rather than a pixel
based graphics library such as GTK. Ncurses is a character based graphics library that has been
used to develop command line utilities and tools such as editors.
ncurses documentation
To 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 of
how to build air_hockey.
To remove the build files, you can do a "make clean". This will remove the executable and the
associate object files (*.o). This is useful prior to committing files to the repository because you
typically do not want to include generated files in the repo.
$ 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
$
$ make clean
make clean
rm -f *~ core /*~
rm -f air-hockeyBuilding the Game
The game should be built following the below logical progression. You will start working on
smaller tasks that we call: 'get-to-know-the-code-base' before making bigger changes to the
codebase. 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 player
controls.
The 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, the
game should terminate gracefully without causing a segmentation fault.
rm -f *.o
$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 playing
surface.
The puck needs to be struck with the mallet and the puck must fully drop in the goal area to
be 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 display
information 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 the
number 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 goal
area, 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 the
start of the game. The width of the goal area should be less than the width of the zone. Pages 5
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 and
obstacles 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 they
must not be placed on the walls.
Coloring the game
Add color to the game to make it more visually appealing. Use the ncurses library to
implement colors. Refer to the relevant section of the ncurses documentation for details on
how to use colors.
What to turn in.
Check your game into your assignment_3 branch. The TAs will checkout this branch, make
the 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.Find a page…
Home
Assignment3
Air Hockey Project
Objectives:
Game levels
Preliminary Steps
File Descriptions
Overview:
Building the Game
Part 1:
Welcome screen
Moving the Players
Pausing the Game
Ending the Game
Increase the slider size from 4 configurable up to 7.
Scoring the Game
Game Over Screen:
Part 2:
Implement win-lose scenario:
Save 10 best win scores:
Set up the goal area:
Different difficulty levels - Obstacles and Speeds
Coloring the game
What to turn in.
Scoring (worth 135 points)
Github Setup Instructions
GNU Debugging
Introduction to Linux and Coding with Makefile
Clone this wiki locally


联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!