207 - Beginning your Project
The last of the taught laboratory sessions will prepare you for the independent project
work over the remaining weeks of the module. Over the last several laboratory sessions
you have learned many things and the project is your chance to put them into practice to
develop your own hand-held game.
The game could be something along the lines of
Asteroids
Snake
Pac-Man
Frogger
Pole Position
Copter
Game Design Patterns
Although there is not ‘one-size’ fits all approach to game design, the ‘game loop’ appears
very frequently1
.
init_game();
while(1) {
process_input();
update_game_state();
refresh_display();
wait_ms(1000/fps);
}
The game loop will be entered after the game is initialised. The first step is to process the
user input (if any). The next step is to update the game engine depending on the input i.e.
moving a character or checking for collisions. The final step is to update the display and render
this on the LCD. There is usually a delay that keeps the game running at a constant number
of frames per second (fps).
Libraries and example code
As well as the N5110 library for interfacing with the LCD, you will also be provided with a
library that allows easy interaction with the gamepad PCB. The API can be found here:
1 Robert Nystrom, Game Programming Patterns. Genever Benning, 2014. A free online version is available:
http://gameprogrammingpatterns.com
CAE 2
https://developer.mbed.org/users/eencae/code/Gamepad/docs/tip/
An example ‘Pong’ project will be available to give an example of how to develop and structure
a typical game. This is not an example of a project that would score 100%, it is simply an
example of how to break a game down into a series of classes.
https://developer.mbed.org/users/eencae/code/Pong/
Creating your Project
It is extremely important that you follow these simple steps in order to correctly create
your project. This will avoid issues when submitting your project. Note that if you
incorrectly submit your project and have to re-submit after the deadline, the standard 5%
per day penalty will apply.
It is therefore in your best interests to carefully follow these steps!
Step 1 – Create a new program
On your Mbed compiler, create a new project for the K64F platform.
New/New Program…
You should use your username as the project name. For example, my project would simply
be called:
‘eencae’
not
‘ELEC2645_Project’
or even
‘ELEC2645_Project_eencae’
just
‘eencae’
This allows me to easily identify your project in the Mbed group. Do not re-use or re-name
another project; create a fresh project.
CAE 3
Step 2 – Comment Block
Copy and paste the following comment block in main.cpp and fill in details:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name:
Username:
Student ID Number:
Date:
*/
Step 3 – Adding in Libraries
Import the libraries for the LCD and Gamepad into the project.
https://os.mbed.com/users/eencae/code/N5110/
https://os.mbed.com/users/eencae/code/Gamepad/
If you decide to use the Accelerometer/Magnetometer library, then also add this in.
Step 4 – Convert Libraries to Folders
Right-click on each library and select ‘Convert to Folder’. This avoids problems when
submitting the code to the Mbed group. You can tell that it has worked correctly if the gear
disappears from the folder icon.
Step 5 – Commit Changes
Commit the changes to your blank project template with the message ‘initial commit’ by
pressing the Commit button on the Mbed compiler. This is so I can see when you started
work on your project.
Creating Your Own Classes
Create a new folder for each class by right-clicking on your project and selecting
New/New Folder…
You can then create a new file for both the .h and .cpp file and keep them in the appropriate
folder.
CAE 4
Using Doxygen
Each class definition (in the header) must be documented for the Doxygen documentation
to be correctly created. Use the brief, author and date commands.
/** My Sample Class
* @brief Does nothing useful
* @author Craig A. Evans
* @date Feb, 2017
*/
class MyClass {
Each of the public methods must also be documented to create the API.
class MyClass {
private:
int _score;
public:
/** Constructor */
MyClass();
/** Destructor */
~MyClass();
/** Set the score
* @param the value of the score (int)
*/
void set_score(int score);
/** Get the score
* @return the current score
*/
int get_score();
};
Use the param and return commands to explain what each public method does.
To create the actual documentation, select
Compile/Update Docs
in the Mbed compiler. You will see some blue folders appear in your program directory.
CAE 5
If you select your class, you will see the class reference API in a new tab. It will also appear
on the Mbed webpage after you have published your code. This is what will be inspected
when assessing your project documentation.
Version Control
You should regularly commit changes to your project. This is usually done after a new
feature is added in to the code and tested to ensure it functions correctly. In this way, if you
add in a new feature and end up breaking the functionality of the existing code, you can
simply revert back to a previous, known working version.
Simply press Commit in the Mbed compiler and add in a useful message to explain what
changes have been made in this revision.
Pressing the Revision button shows a history of commits and allows you to compare
versions, see changes and revert back to an earlier revision.
The commit history will also appear on the Mbed webpage after you have published your
code.
CAE 6
Submission
Your code will be submitted to a group on the Mbed website as well as through Minerva.
You can request to join the group via the link below.
https://os.mbed.com/teams/ELEC2645-201819/
Submit the code by pressing
Commit/Publish
on the Mbed compiler. The text for your final commit should be:
“Final Submission. I have read and agreed with Statement of Academic Integrity.”
This will time-stamp your submission. Submissions after the deadline will not be marked –
the last submission before the deadline will be marked.
You will then be able to publish your program. Ensure you select the settings shown in the
image below.
Add your name and SID in the description box, publish as a program in your ELEC2645
group. Ensure you select the visibility to be private.
CAE 7
When you publish, you will be given a link. Make a copy of this link as you will need it when
submitting on Minerva.
This is the reason why it is very important to simply name your project after your IT
username.
Plagiarism
To check for plagiarism, your source code will be run through JPLag.
I have a repository of all the ELEC2645 project code submitted in previous years. All the
code submitted this year will be added to the repository along with the code submitted by
students in the SWJTU Joint School in China.
This means that your code will be compared against all your classmates code, students in
the Joint School as well as former students. Any similarities that are highlighted will be
investigated fully. A module mark of 0 or exclusion from University are likely punishments
for cheating on such a large piece of coursework.
Please also remember that your code will be published in the group along with information
that will enable you to be identified (such as your name in the main.cpp). Therefore, if you
plagiarise code, it will be publically visible and will bring great shame to you, not to mention
the University!
Right-click on your project in the Mbed compiler and select Export Program…
Select ‘ZIP Archive (with repositories)’ in the export toolchain.
Upload the .zip file to Minerva and paste in the link to your project (on the Mbed group) to
the submission details.
Your submission will not be deemed complete until you have published your
code in the group AND uploaded the .zip to Minerva. The standard 5% daily late
penalty will be applied.
Summary
Please follow these steps carefully! If you do not correctly create or submit your project
you are very likely to lose marks. If so, don’t come complaining after you get your marks
back, it is your responsibility to correctly create and submit your project, not mine!
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。