Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

Hello, soldier, you have been specially selected as the defender of planet earth.

Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.

But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.

As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.

Committer:
evanso
Date:
Tue May 19 15:13:47 2020 +0000
Revision:
48:e308067cfea5
Added sd card class folder to project folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 48:e308067cfea5 1 /* mbed Microcontroller Library
evanso 48:e308067cfea5 2 * Copyright (c) 2006-2012 ARM Limited
evanso 48:e308067cfea5 3 *
evanso 48:e308067cfea5 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
evanso 48:e308067cfea5 5 * of this software and associated documentation files (the "Software"), to deal
evanso 48:e308067cfea5 6 * in the Software without restriction, including without limitation the rights
evanso 48:e308067cfea5 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
evanso 48:e308067cfea5 8 * copies of the Software, and to permit persons to whom the Software is
evanso 48:e308067cfea5 9 * furnished to do so, subject to the following conditions:
evanso 48:e308067cfea5 10 *
evanso 48:e308067cfea5 11 * The above copyright notice and this permission notice shall be included in
evanso 48:e308067cfea5 12 * all copies or substantial portions of the Software.
evanso 48:e308067cfea5 13 *
evanso 48:e308067cfea5 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
evanso 48:e308067cfea5 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
evanso 48:e308067cfea5 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
evanso 48:e308067cfea5 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
evanso 48:e308067cfea5 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
evanso 48:e308067cfea5 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
evanso 48:e308067cfea5 20 * SOFTWARE.
evanso 48:e308067cfea5 21 */
evanso 48:e308067cfea5 22 #include <string.h>
evanso 48:e308067cfea5 23 #include "ff.h"
evanso 48:e308067cfea5 24 #include "FATDirHandle.h"
evanso 48:e308067cfea5 25
evanso 48:e308067cfea5 26 using namespace mbed;
evanso 48:e308067cfea5 27
evanso 48:e308067cfea5 28 FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) {
evanso 48:e308067cfea5 29 dir = the_dir;
evanso 48:e308067cfea5 30 }
evanso 48:e308067cfea5 31
evanso 48:e308067cfea5 32 int FATDirHandle::closedir() {
evanso 48:e308067cfea5 33 int retval = f_closedir(&dir);
evanso 48:e308067cfea5 34 delete this;
evanso 48:e308067cfea5 35 return retval;
evanso 48:e308067cfea5 36 }
evanso 48:e308067cfea5 37
evanso 48:e308067cfea5 38 struct dirent *FATDirHandle::readdir() {
evanso 48:e308067cfea5 39 FILINFO finfo;
evanso 48:e308067cfea5 40
evanso 48:e308067cfea5 41 #if _USE_LFN
evanso 48:e308067cfea5 42 finfo.lfname = cur_entry.d_name;
evanso 48:e308067cfea5 43 finfo.lfsize = sizeof(cur_entry.d_name);
evanso 48:e308067cfea5 44 #endif // _USE_LFN
evanso 48:e308067cfea5 45
evanso 48:e308067cfea5 46 FRESULT res = f_readdir(&dir, &finfo);
evanso 48:e308067cfea5 47
evanso 48:e308067cfea5 48 #if _USE_LFN
evanso 48:e308067cfea5 49 if(res != 0 || finfo.fname[0]==0) {
evanso 48:e308067cfea5 50 return NULL;
evanso 48:e308067cfea5 51 } else {
evanso 48:e308067cfea5 52 if(cur_entry.d_name[0]==0) {
evanso 48:e308067cfea5 53 // No long filename so use short filename.
evanso 48:e308067cfea5 54 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
evanso 48:e308067cfea5 55 }
evanso 48:e308067cfea5 56 return &cur_entry;
evanso 48:e308067cfea5 57 }
evanso 48:e308067cfea5 58 #else
evanso 48:e308067cfea5 59 if(res != 0 || finfo.fname[0]==0) {
evanso 48:e308067cfea5 60 return NULL;
evanso 48:e308067cfea5 61 } else {
evanso 48:e308067cfea5 62 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
evanso 48:e308067cfea5 63 return &cur_entry;
evanso 48:e308067cfea5 64 }
evanso 48:e308067cfea5 65 #endif /* _USE_LFN */
evanso 48:e308067cfea5 66 }
evanso 48:e308067cfea5 67
evanso 48:e308067cfea5 68 void FATDirHandle::rewinddir() {
evanso 48:e308067cfea5 69 dir.index = 0;
evanso 48:e308067cfea5 70 }
evanso 48:e308067cfea5 71
evanso 48:e308067cfea5 72 off_t FATDirHandle::telldir() {
evanso 48:e308067cfea5 73 return dir.index;
evanso 48:e308067cfea5 74 }
evanso 48:e308067cfea5 75
evanso 48:e308067cfea5 76 void FATDirHandle::seekdir(off_t location) {
evanso 48:e308067cfea5 77 dir.index = location;
evanso 48:e308067cfea5 78 }
evanso 48:e308067cfea5 79
evanso 48:e308067cfea5 80 ssize_t FATDirHandle::read(struct dirent *ent) {
evanso 48:e308067cfea5 81 struct dirent *temp = readdir();
evanso 48:e308067cfea5 82 if (!temp) {
evanso 48:e308067cfea5 83 return 0;
evanso 48:e308067cfea5 84 }
evanso 48:e308067cfea5 85
evanso 48:e308067cfea5 86 memcpy(ent, temp, sizeof(*ent));
evanso 48:e308067cfea5 87 return 1;
evanso 48:e308067cfea5 88 }
evanso 48:e308067cfea5 89