首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导ECS 36A程序、Programming编程设计辅导、C/C++程序讲解 讲解数据库SQL|讲解SPSS
项目预算:
开发周期:
发布时间:
要求地区:
ECS 36A: Programming Assignment #7
Fall 2020
Contents
1 Changelog 1
2 General Submission Details 1
3 Grading Breakdown 1
4 Submitting on Gradescope 1
4.1 Regarding Autograder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4.1.1 Game Files by Visible Test Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4.1.2 Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4.1.3 Memory Leaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
5 Game 2
1 Changelog
You should always refer to the latest version of this document.
• v.1: Initial version.
• v.2: Added statement in red: “You may assume that the user only enters one character at a time.”
• v.3: Autograder details.
2 General Submission Details
Partnering on this assignment is prohibited. If you have not already, you should read the section on
academic misconduct in the syllabus.
This assignment is due the night of Monday, December 14. Gradescope will say 12:30 AM on Tuesday, December 15, due
to the “grace period” (as described in the syllabus). Be careful about relying on the grace period for extra time; this could be
risky.
You should use the -Wall and -Werror flags when compiling. The autograder will use these flags when it compiles your
program.
3 Grading Breakdown
The autograder score will be out of 120 points.
4 Submitting on Gradescope
You should only submit game.c. You may be penalized for submitting additional files. You have infinite submissions until
the deadline.
During the 10/02 lecture, I talked about how to change the active submission, just in case that is something that you
find yourself wanting to do.
∗This content is protected and may not be shared, uploaded, or distributed.
1
4.1 Regarding Autograder
Your output must match mine exactly.
There is a description about how to interpret some of the autograder error messages in the directions for the previous
two programming assignments. I will not repeat that description here.
The autograder uses the same main.c file that was used in the examples.
As always, make sure to compile on the CSIF if the autograder reports that you have compiler error messages even though
you don’t find compiler error messages on your end.
4.1.1 Game Files by Visible Test Case
Case Number Game File
1 game files/game4.txt
2 game files/game5.txt
3 game files/game6.txt
5 game files/game6.txt
7 game files/game6.txt
9 game files/game4.txt
11 game files/game4.txt
12 game files/game1.txt
14 game files/game10.txt
15 game files/game10.txt
16 game files/game10.txt
17 game files/game10.txt
19 game files/game3.txt
21 game files/game2.txt
4.1.2 Inputs
For each test case, I uploaded a text file containing the inputs. You can use input redirection (from chapter 6 of your
Linux reading); for the larger test cases, this is more convenient than typing all of the inputs in, as some of the cases enter
at least 100 inputs.
4.1.3 Memory Leaks
Two of the test cases (#19 and #20) check for memory leaks.
5 Game
For this assignment, all that you have to do (in game.c) is implement one function: the function playGame() that is declared
in game.h. You will only submit game.c, so any changes that you make to game.h will be ignored. The function
playGame() should load data from the file whose name is passed to it and then allow the user to play a game. In this game, the
player is represented by a single character on a board. In the below, the asterisks form the border of the board, the A is the
player’s icon, each X represents an enemy, the * (in the middle of the board) represents a “power orb”, and each $ represents
an item. There are also two buildings on the board.
playGame() reads the contents of the board from a file. Below is the file that corresponds to the above board. You may
assume that the input file is properly formatted; input validation is not a part of this assignment.
First two lines: The first line contains the dimensions (height and width, respectively) of the board, not counting the
borders (i.e. the asterisks). The second line contains the five keys that the user will use to move left, move right, move
upwards, move downwards, and quit (respectively). It is possible that this line of the file is empty, in which case a set of
default keys (left: ‘a’, right: ‘d’, up: ‘w’, down: ‘s’, quit: ‘q’) should be used. Either all five keys will be provided, or none
will be provided.
Player line: The third line starts with the default icon used to represent the player. In the above file, this is ‘A’, which
is why A was the player’s icon in the above map. The ‘B’ is the powered icon, which I talk more about below. Then, there
are the starting coordinates (y-coordinate and x-coordinate, each zero-based) of the player. Note that a y-coordinate of 0
corresponds to the top row of the board, not the bottom row. Also note that the player’s icon could be the same as the
item’s icon.
Bulding, enemy, item, and power orb lines: The game file will always have at least one item (you may assume this),
but it may have zero buildings, zero enemies, and/or zero power orbs. At this point in the file, you will have the lines for
the buildings (if any, and each starting with a ‘B’), followed by the lines for the enemies (if any, and each starting with an
‘E’), followed by the lines for the items (each starting with an ‘I’), followed by the lines for the power orbs (if any, and each
starting with a ‘P’). For each of these kinds of lines, the special character is followed by the coordinates. Like the player,
each of an enemy, an item, and a power orb take up one spot. A building always looks the same as you see it in the example
above. That is, a building is always a 4-by-6 block of dashes, except for a “door” built with ampersands in the middle of
it. In the case of a building, the provided coordinates locate its top-left. You may assume that there are no overlapping
elements, e.g. there won’t be an item inside of a building. You may assume that everything is in bounds, e.g. there won’t be
a building that is halfway outside the boundaries of the board.
End conditions: The game ends when any of the below conditions occur. Depending on which end condition is
achieved, your program should print a specific message; see the examples below. The player is always shown their ending
score. Moreover, if the player loses by dying, then the board is shown one extra time; one of the examples emphasizes this.
• The player quits using the quit key.
• The player wins by collecting all of the items.
• The player dies.
Input and collision detection: When prompting the user for input, if they do not enter one of the four movement keys
or the quit key, then they should be prompted again (see the examples below). You may assume that the user only enters
one character at a time. Each movement key attempts to move the player one unit in the indicated direction. Certain events
occur based on what the player interacts/collides with:
• Borders: The player is prevented from going through the board’s borders.
• Building: The player is prevented from going through the building.
• Item: The player collects the item, removing it from the game.
• Power orb1
: When the player touches a power orb, they enter “power mode”. While they are in power mode, their
icon is the powered icon that was mentioned above, instead of the default icon. They remain in power mode during
their next 7 inputs. This duration is reset/replenished (back to 7) if they touch another power orb during this time.
Note that during the last input in which the player is in power mode, their power mode should run out immediately
after they enter their input / before collision detection is done; see one of the examples below, where I specifically
comment about this. Also note that the duration goes down even if the player’s input is wasted, e.g. if they spent the
next 7 inputs trying to move into a wall (and thus move nowhere), then the power mode will expire.
• Enemy:
– If NOT in power mode (default): The player dies, and the game ends. As stated in the end conditions above, the
board should be printed one more time in this case, and the player’s icon will be a @ (that’s the character that I
felt most looked like an explosion).
– If in power mode: The player removes the enemy from the game.
1Power orbs mimic the behavior of “power pellets” in the game Pac-Man.
3
Indicators: As you can see in the examples, I’m always shown the current score and the number of items remaining.
The score is incremented whenever an item is collected or (while in power mode) an enemy is destroyed/eaten2/collected.
Here are some suggestions that you may or may not find helpful:
• After performing some setup, your game could go to what we will call its “main loop”, which is the loop that keeps the
game going until an end condition is satisfied. In each iteration of this loop, the game should be drawn, and then user
input should be obtained, and then updates (movement, collision detection, etc., where applicable) should be performed.
• I would start small and make sure things still work as you make gradual, carefully thought out changes. An example of
this would be to start with a file that only contains the bare minimum requirements, i.e. the first three lines and then
a single item, all on a small board. Don’t try to type a lot of code at once without pausing to check if any of it works.
• I used a lot of helper functions to organize my code when I thought it would help me think about the different steps.
Here are examples of helper functions that I had: setupBoard(), loadKeys(), drawBuilding(), getInput(). Each helper
function identifies a clear step, and this helped me to write my solution in a methodical manner.
• I lost a bit of time dealing with that the second line could be blank because I was using a mix of fgets() and fscanf()
to read the file. If you put a newline character at the end of the format string of fscanf() and there are two newline
characters in a row (which occurs when the second line is blank), fscanf() will read both (not just one) of those newline
characters (after reading whatever else it was supposed to read according to the format string).
Memory leaks: Your program should have none, and you should close any files that are opened.
Below is a list of headers that you are allowed to include in game.c. You may not need all of these.
• game.h
•
•
•
•
•
•
•
Below are examples of how your code should behave. You can find all of the demo files (e.g. main.c, game2.txt) on Canvas.
1 $ cat main .c
2 # include " game . h"
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!