2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
CAB202 Assignment 1, Exercise 1: Assignment 1
List
Return to Exercise
Current Score: Your score on this submission was 100 out of 100 (0%). Best Score: Your best score for this exercise is 100 out of 100 (0%).
Assessed weight: 0%. This item is not assessed. You may continue to attempt this item until you reach 30 submissions. So far, you have made 1 submission.
CAB202 Assignment 1
Due Date: 23:59:59 (AEST) Monday 10th of September 2018
Marks: 30 (30% of your final mark)
FAQ
For this assignment, you will be writing a computer program that emulates a player moving
through a series of static and moving blocks. The aim of the player is to move/jump
between blocks while gaining points and lives.
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 1/14
:stnemeriuqeR
:raf os stluseR
|
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1 Assignment Specifications This assignment is divided into different sections, however you may attempt the sections in any order you see fit. You may attempt other sections even if you have not fully completed the Basic Functionality. You will submit documentation as per the instructions given below and you will be marked on a combination of your documentation and your program. You will need to do both well to get the full marks. If you submit code without the specified documentation you will be marked down, conversely, if you submit documentation for aspects you have not implemented or documentation that does not accurately reflect your program, you will be marked down. If your program crashes, you will be marked for the sections your marker was able to test before the program crashed. Please test your code regularly to minimise your chance of this happening. You can make multiple submissions to AMS and you are encouraged to do so. Basic Functionality (15 Marks) 1. The display screen is 5 characters high, located at the top of the screen, is
entirely visible at all times (i.e. never occluded in any way) and displays:
a. Student number,
b. Lives remaining,
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 2/14 |
2018/9/9
CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
2.
c. Playing time in minutes and seconds format as mm:ss, d. Score, e. Border that separates the display screen from the game area.
The player initially appears on a ‘starting block’ in the top row. The player’s
sprite is at least 3 characters high and 3 characters wide. 3. All blocks are:
a. 2 characters high,
b. At least 7 characters wide (unless Advanced Functionality is implemented) and
are clearly distinguished from each other (through characters in bitmap or
spacing between sprites),
c. Always at least characters vertically away from other
blocks. 4. Columns are calculated as
+ horizontal
spacing (if used to distinguish between sprites) and there are:
a. The number of blocks on screen is proportional to the number of columns, to a
maximum of 160 safe blocks and 40 forbidden blocks,
b. At least 1 safe block per column denoted by '=' on the screen at all times,
c. At least 2 forbidden block on the screen denoted by 'x' on the screen at all
times. 5. Blocks have no consistent observable pattern and each block:
a. Appears in a randomly selected row,
b. Appears in a randomly selected column (after there is 1 safe block per
column),
c. Does not overlap other blocks or the display screen. 6. Player movement behaves such that:
a. Pressing the ‘a’ or ‘d’ key moves the character left and right respectively,
b. The player can not overlap the display screen.
c. When off a block, the player free falls downwards at an appropriate speed,
d. No lateral motion occurs during downward motion (unless Advanced
Functionality is implemented). 7. There is a treasure sprite that:
a. Is no larger than the player's sprite and has a clearly distinct image,
b. Spawns at the bottom of the screen and moves back and forward along the
bottom, changing horizontal direction when it reaches the edges of the
screen,
c. Stops moving when 't' is pressed and starts moving again if 't' is pressed
again (i.e. motion toggles on and off when 't' is pressed),
d. Disappears when the player collides with it and gives the player
and returns the player to the 'starting block'. 8. The following game mechanics are present:
more lives
a. The player starts with lives.
b. A point is scored every time the player lands on a safe block.
c. The player dies when they fall off the bottom of the screen or hit a
forbidden block. On death, the player starts from the ‘starting block’
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 3/14
2
htdiw kcolb xam / htdiw neercs elbisiv
2 + thgieh etirps
01
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
(unless Advanced Functionality is implemented).
d. When the player loses all their lives, the game over screen is displayed
which displays a game over message, total score, and game play time.
e. The game over screen allows the player to restart by pressing ‘r’ (score,
lives, time, and screen all reset) or quit with the ‘q’ key which ends the game gracefully.
Advanced Functionality (7 Marks)
9. Each block has a random width between 5 and 10 and:
a. The top and bottom rows of blocks remain stationery, but the blocks in other
rows move at appropriate speeds (different rows may have different speeds),
b. Blocks in the same row move at the same speed and direction,
c. Blocks reappear on the other side of the screen as they go off the screen,
d. Each row of blocks moves in opposite directions or speeds to the row directly
above (e.g. if row 2 moves left, row 3 could move right), 10. Player motion is controlled as follows:
a. An 'a' or 'd' key press gives the player a horizontal velocity so that if 'a'
or 'd' is pressed on a moving block, the player moves along the block
accordingly,
b. When on a block, a 'w' key press gives the player a vertical velocity upwards
(pressing 'w' again does not do anything until player lands again),
c. When the player lands on a block their vertical velocity changes to zero and
they adopt the same horizontal velocity as the block,
d. If the player is on a block and any part of the block goes off screen, the
player loses a life and respawns.
11. A constant vertical acceleration (i.e. gravity) acts downwards at all times,
generating a reasonably realistic ballistic motion effect when the player is in
flight after stepping or jumping from a block. Gravity generates the following
visually observable behaviour:
- When on a block, the effects of gravity are eliminated – the player does not fall through the block,
- When jumping, the player’s vertical velocity is slowest at the peak jump height,
c. When jumping with a horizontal velocity, the player traces a parabolic path.
The horizontal velocity is constant, while the vertical velocity increases at
a constant rate with passage of time,
d. When falling with a non-zero horizontal velocity, the player also traces a
parabolic path but starts with zero vertical velocity,
e. When hitting the side of a block, the player’s horizontal velocity becomes zero.
12. Player randomly respawns on any of the top row safe blocks after dying (doesn't
just reappear on the 'starting block').
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 4/14
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
Advanced Graphics (4 Marks)
13. The treasure has some sort of animation. 14. The player's image changes when:
a. The player falls or when they jump,
b. The the player is moving left,
c. The the player is moving right,
d. The player is stationery or only moving with the blocks.
15. The player has some sort of animation every time the player respawns.
Advanced Coding Practices (4 marks)
16. Your program has minimal code duplication and is cleanly structured for a human
reader.
17. You have used arrays or pointers where appropriate. 18. Your program is composed of functions. A function should only perform one task and
not exceed 20 lines of code. 19. You have used parameters where appropriate and minimised the number of global
variables.
Documentation
Your documentation must be clearly written, formatted appropriately, follow the structure in the template, and include:
A cover page with your full name, student number and assignment date,
A contents page,
A list of all the features outlined above and which ones you have attempted as per
,
A heading, linked to the contents page, for each section,
Test plans for all functionality implemented from the Basic Functionality and Advanced Functionality sections as per . You do not need to write a test plan for items you have not implemented,
A brief description of you have implemented from the Advanced Graphics section and it can be observed,
A written explanation of and you implemented what you have from the Advanced Coding Practices.
Use the templates below, and/or the Word document provided on Blackboard, for your documentation.
Table 1
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 5/14
2 elbaT
.airetirc hcae ni skram lluf rof detnemelpmi evah uoy ytilanoitcnuf eht lla tnemucod tsum uoY
yrammuS noitatnemelpmI tnemngissA
woh yhw tahw
woh
1 elbaT
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
1
Display screen
Partially implemented
2
Player size and initial position
Fully implemented
3
Block size and spacing
Not implemented
4
Blocks are randomly positioned.
5
Columns and block types
6
Player movement
7
Treasure
8
Basic game mechanics
9
Block width and movement
10
Advanced player movement
11
Ballistic motion
12
Player random respawning
13
Treasure animation
14
Player movement animation
15
Player respawn animation
16
Minimal duplication
17
Arrays or pointers
18
Functions
19
Parameters
Table 2: Test Plan Example
Display screen is 5 pixels high, at top of screen and is entirely visible at all times. |
Run game and press 'w' for player to jump. |
Player and blocks should never cross the display screen. |
Player can jump into display screen. |
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 6/14
tluseR tluseR detcepxE lautcA
snoitcA dna ytilanoitcnuF puteS tseT cificepS fo tseT
leveL noitatnemelpmI
noitpircseD metI rebmuN metI
neercS yalpsiD
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
Lives remaining are displayed in the status display area.
Run game and die.
Lives should be displayed towards the right of the display screen area and decrease on death.
As expected.
Student number is displayed in the status display area.
Run game
Submission Information Important!
1. The assignment will be graded by strict reference to the criteria listed below. 2. Assessment is evidence-based. You must submit a written report via Blackboard
3.
which provides evidence of completion, supported by working source code submitted via AMS. Both items must be submitted by the due date. Absence of either or both will result in a score of 0.
While we encourage you to discuss the assignment and brain-storm with your associates, you must ensure that your submission is your
own individual work.
4. A high standard of academic integrity is required. Breaches of academic integrity, including plagiarism or any other action taken to subvert, circumvent, or distort the assessment process, will not be tolerated. QUT policy regarding academic conduct is available in the QUT MOPP Section C/5.3 Academic Integrity (http://www.mopp.qut.edu.au/C/C_05_03.jsp). In particular, under the provisions of MOPP statement C/5.3.7 (http://www.mopp.qut.edu.au/C/C_05_03.jsp#C_05_03.07.mdoc), Part (e), we reserve the right to require you to authenticate your learning. You may be required to show evidence of materials used in the production of the assignment such as notes, drafts, sketches or historical backups. You may also be required to undertake a viva or complete a supervised practical exercise.
5. Use of any third-party code library (other than the ZDK and those supplied with a standard distribution of GCC and ncurses) is strictly prohibited. Use of code downloaded from the internet without correct attribution to the original author(s) is strictly prohibited. Subcontracting, outsourcing, off-shoring, purchasing, borrowing, stealing, copying, or obtaining source code or report content by any means other than through an act of original creation by yourself, is strictly prohibited.
6. Abundant code samples, demonstrations, and exercises have been made available to support your effort toward this programming task. Written permission must be
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 7/14
Student number should be displayed in the left of the display screen.
As expected.
!edoc ton ,saedi erahS
.tnemngissa puorg a ton si sihT
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
obtained from the Unit Coordinator if you want to use technology other than the ZDK to implement your game. Permission will only be granted if there are compelling special circumstances that make it impossible for you to use the ZDK. Without this permission, a game implemented with some other graphical framework will receive a score of 0. Direct use of the ncurses library to render graphics or text is expressly prohibited.
Deliverables
1. Report, submitted via Blackboard
Submit a succinct and well-presented written report which accurately describes
your program and how you have tested it. You may refer to QUT Cite Write
(https://www.citewrite.qut.edu.au/write/report.jsp) for information on the general
guidelines for writing a report. For convenience we provide a word template.
The report is your primary assessable item.
The report is the medium through with you will convince your tutor that the
program you have written is in fact a solution to the task that has been set. It
a copy of the source code of your program. It needs to contain enough
information to convince an intelligent reader (who may not necessarily have a
background in software engineering) that you have done what you claim to have
done. The reader should be able to see easily in the report how you have tested
the respective features, and whether they work as claimed.
The report should contain one section with the summary of the features that you
implement and one section with the test plan and results. Refer to the report
structure template in the specification in AMS and the Word document on
Blackboard.
Implementation Summary.
Provide indication whether the requested feature was fully, partially or
not implemented.
Test plan and results.
The most appropriate format for this is the template provided. Do not
submit screenshots of the program or code.
Some features may require several tests.
Your mark for each feature will be awarded based what you document that you have
done. Make sure you cover all relevant features in your documentation and
implementation, and supply evidence of comprehensive testing to back it up.
2. Source code submitted via AMS
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 8/14
.troper ruoy ni edoc ecruos eht fo ypoc a edulcni ton oD
ton si
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
Please Read
Marking
The assignment is worth 30% of your total grade in this subject, and it is marked out of 30. The breakdown of marks is outlined in the previous section. The following points should be noted about marking:
1.
Give yourself plenty of time to get the basics right.
Submit Early. Submit Often. 2. If the program has been implemented via a framework other than the ZDK without
prior written permission from the Unit Coordinator, the mark awarded will be 0. 3. If the program fails with segmentation faults or other fatal errors, marks will be
awarded for the features that were observed prior to the crash.
No effort will be made to work around the crash, nor will we debug your code to make it compile or run.
Your program must compile and run well on any modern desktop machine equipped with a Unix-like environment.
To this end, part of your job is to test the program in a variety of environments, including (as a minimum) QUT lab machines using the CAB202 portable Cygwin environment.
“It runs fine on my computer!” may be true, but it is largely irrelevant if the program crashes when executed on another machine. Such an excuse will not be accepted.
4. It is your responsibility to implement each feature sufficiently well that it is
readily detected through normal operation of the game. Any feature that is not
apparent through normal play will be deemed to be unimplemented.
5. We require tutors to adhere to a strict time limit of 3 minutes play time when
marking each submission. Any feature that cannot be assessed in that time will be
deemed to be unimplemented. Therefore you must avoid defects in game dynamics such
as extremely fast motion, extremely slow motion, inconsistent control settings,
premature program termination, or other properties that render the game unfit for
use.
Submit full source code for your implementation into AMS using this form.
A working implementation of your program which can be executed by your tutor running the CAB202 Portable Cygwin software is required. Therefore, your program must compile in AMS and the resulting executable program must work as stated in your report.
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 9/14
.0 eb lliw dedrawa kram eht ,SMA ot dettimbus nehw elipmoc ton seod edoc ruoy fI
.SKRAM ON :NIWGYC ELBATROP HTIW ENIHCAM DRADNATS NO NUR ON .SKRAM ON :SMA NI ELIPMOC ON .SKRAM ON :TROPER ON
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
6. It is better to implement some of the features extremely well than to try to do
everything and deliver a substandard product.
7. Penalties will be applied if the code exhibits general defects or undesirable
behaviour not otherwise covered in this document. This includes but is not limited
to such things as:
Errors in object motion, such as objects/player jumping more than one
character position per frame;
Objects moving outside their permitted area;
Failure to clear the screen appropriately between updates;
Collisions involving invisible or non-existent objects;
Disturbing or flashing display;
Failure to purge the keyboard buffer at appropriate times.
Gratuitous errors in program structure, including but not limited to:
inappropriate use of recursion; use of inappropriate data structures such as
linked lists or binary search trees.
Notes:
Use "Attach file" to submit your solution. You may attach your solution in one C file or, if your solution is in multiple C source files and header files, you can attach a single copy of each file.
Do not attach multiple versions of your solution.
Files with names ending with a pattern other than .c or .h will be rejected. Please ensure that your naming convention takes this limitation into account.
A maximum of 30 files may be included in each submission. This consists of the built-in "submission.c" document, plus 29 attachments.
When you have attached all required files, press the "Submit" button.
Source files for each submission will be placed in a single distinct folder on the server, and compiled with the following command:
gcc *.c -std=gnu99 -Wall -Werror -I../ZDK -L../ZDK -lzdk -lncurses -
lm -o a1_n9999999
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 10/14
!!! elif yna fo noisrev eno naht erom edulcni ton oD !!!
.airetirc tnemssessa eht tsniaga dekram eb lliw ti dna etad eud eht yb detelpmoc evah uoy krow eht timbus dluohs uoy noisnetxe devorppa na evah t’nod uoy fI .etad eud tnemngissa eht erofeb )snoisnetxe -dna-stnemngissa-etal/tnemssessa/gniyduts/ua.ude.tuq.tneduts.www//:sptth( noisnetxe na rof ylppa nac uoy ,etad eud tnemssessa eht gniteem morf uoy tneverp secnatsmucric laiceps fI .dekram eb ton lliw noisnetxe devorppa na tuohtiw snoissimbus etal ,ycilop TUQ htiw enil ni revewoh ,snoissimbus rof nwod-esolc drah a ecrofne ton lliw SMA .yllacitamotua tnemngissa eht ssessa ot elba ton si metsys eht taht snaem ti – elbassessa-non si tnemngissa eht naem ton seod sihT .dessessa-non sa deifissalc neeb sah ytivitca siht ,tnemssessa SMA fo sesoprup roF
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
where n9999999 represents your student number.
Note that the wildcard pattern *.c will compile files with a name that ends
with the extension .c in the present working directory.
Therefore, you should organise your files in a folder alongside the ZDK folder and
use this command to build your solution. Make sure there are no additional files
(such as old versions of your program) in your work folder which may cause
unpredictable build errors and/or run-time behaviour.
It is your responsibility to use this compile command locally to verify that your
project will compile before submission.
If you are using the #include directive to connect multiple C source files, the #included files should be renamed to have an extension of .h to avoid errors arising from multiple definition of functions. However, in general you should not include anything other than .h files in the first place.
If compilation is successful, AMS will verify that your program has compiled
successfully, and then return. Your program will be executed because there is
no meaningful test that can be performed automatically on a program such as this.
The score allocated by AMS for this task is not your mark for the assignment.
FAQ:
The max numbers are provided so you do not have to dynamically allocate memory for an array. Your game will be tested at very large screen sizes so you have a scenario where you are unable to allocate 1 safe block per column. You do to do anything with a ratio.
There needs to be at least 1 safe block per column when the game starts. If the blocks start moving such that this criterion is no longer fulfilled it is okay! The same goes for forbidden blocks.
This should read “opposite directions and different speeds”. Your rows MUST initially move in opposite directions and at different speeds to the row above. Apologies if any of the tutors told you something different, please follow this! It should not be difficult to change.
Blocks should never overlap each other.
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 11/14
)thgir evom dluoc 3 wor ,tfel sevom 2 wor fi .g.e( evoba yltcerid wor eht ot sdeeps ro snoitcerid etisoppo ni sevom skcolb fo wor hcaE .d9
semit lla ta neercs eht no ‘=’ yb detoned nmuloc rep kcolb efas 1 tsael tA .b4
EVAH TON
TON LLIW TON
skcolb neddibrof 04 dna skcolb efas 061 fo mumixam a ot ,snmuloc fo rebmun eht ot lanoitroporp si neercs no skcolb fo rebmun ehT .a4
ton
lla
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 12/14
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
a1.c ×
选择文件
未选择任何文件
Blocks should “teleport” to the other side of the screen. This means that when the left side of the block < left side of the screen, it disappears and appears on the right side. When the left side of the block < left side of the screen and the player is on that block, player loses a life and respawns at the top. The same logic applies to the blocks on the right side of the screen.
The player should teleport. If a tutor has told you something different, !
If you want blocks to gradually disappear and appear on the opposite side, that is acceptable but no extra marks will be given for this.
If the player jumps off a block and the trajectory is off screen, the player should die as soon as the left side of the player leaves the left side of the screen and then respawn. The same logic applies to the right side.
This criteria is intended to stop the player overlapping the blocks. If your block is moving, and the player is going to hit the side of the block, you can step the player back to the first position where it is not overlapping the block and then make the player fall directly down.
The image of a non-walking, non-jumping player should be different to the jump and walking animations.
How can be a brief summary of what other advanced coding practice points you have implemented. You will explain further in documentation for the specific points.
For the why, you need to explain why it’s important. This can be from personal opinion and/or experience. Or you can research. If you research, please include references in your preferred style outlined in QUT Cite / Write. References are not marked but we will check plagiarism and if multiple students use the same unreferenced source, you will have a high level of plagiarism for this point.
:elif hcattA
:selif dettimbuS
.redaer namuh a rof derutcurts ylnaelc si dna noitacilpud edoc laminim sah margorp ruoY .61
.orez semoceb yticolev latnoziroh s’reyalp eht ,kcolb a fo edis eht gnittih nehW .e11
esaelp REVEN
.snwapser dna efil a sesol reyalp eht ,neercs ffo seog kcolb eht fo trap yna dna kcolb a no si reyalp eht fI .d01
.siht enod evah uoy yhw dna woh nialpxE
.skcolb eht htiw gnivom ylno ro yrenoitats si reyalp ehT .d41
siht wollof
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
By submitting this form, I certify that:
I have read, and understand, QUT Manual Of Policy and Procedures, Section C/5.3,
Academic Integrity; and
This submission is in full compliance with all provisions of QUT Manual of Policy and
Procedures, Section C/5.3, Academic Integrity; and
With the exception of support libraries provided to the class by the CAB202 teaching
team, I am the sole author of all source code and attachments included in this
submission.
Agree to these conditions:
Submit
#include <math.h> #include <stdlib.h> #include <string.h> #include <cab202_graphics.h> #include <cab202_timers.h> #include <cab202_sprites.h>
// Configuration #define DELAY (10) /* Millisecond delay between game updates */ #define PLAYER_WIDTH (4) #define PLAYER_HEIGHT (4) #define MAX_BLOCKS (160)
int lives = 10; int score = 0;
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 13/14
noissimbus dna noitaralceD
:tpircsnarT
2018/9/9 CAB202 – CAB202 Assignment 1, Exercise 1: Assignment 1
© 2018 - Queensland University of Technology
Run complete. Reference number: 9989b674-852c-4178-8e8f-a6da5dc8099f.
+------------------+ | Make error text: | +------------------+
+--------------+ | Make output: | +--------------+ ../../permit_fopen_for_a1.bash *.c if [ -f test_59227.c ]; then mv test_59227.c test_59227.bak; fi gcc -std=gnu99 -Wall *.c -o a1_n10314989 -I../../ZDK -L../../ZDK -lzdk -lncurses -lm mv test_59227.bak test_59227.c
gcc -std=gnu99 -Wall test_59227.c -o assignment_1 -I../../ZDK -L../../ZDK -lzdk -lncurses
+------------------+ | Test error text: | +------------------+
+--------------+ | Test output: | +--------------+
https://sefams01.qut.edu.au/CAB202/Exercise?TopicNumber=6&ProblemNumber=1 14/14