Ben Evans University Second Year Project. Game Called Defender.
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.
SavedGames/SavedGames.cpp
- Committer:
- evanso
- Date:
- 2020-05-19
- Revision:
- 52:feb8cf28bcff
- Parent:
- 51:35cb8e604b72
- Child:
- 53:01be7898c23f
File content as of revision 52:feb8cf28bcff:
#include "SavedGames.h" SavedGames::SavedGames() { } SavedGames::~SavedGames() { } void SavedGames::init(SDFileSystem &sd,N5110 &lcd){ error_ = false; check_sd_present(sd,lcd); check_open_file(sd,lcd); } void SavedGames::check_sd_present(SDFileSystem &sd,N5110 &lcd){ if(!sd.card_present()) { error_ = true; //print error screen lcd.clear(); lcd.printString("SD card not ",9,3); lcd.printString(" present ",9,4); lcd.refresh(); wait(3); } } void SavedGames::check_open_file(SDFileSystem &sd,N5110 &lcd){ //opens file FILE *fp; fp = fopen("/sd/SavedGames.text", "a"); //checks if file is opened corectly if (fp == NULL) { error_ = true; //print error screen lcd.clear(); lcd.printString(" Unable to ",9,3); lcd.printString(" open file ",9,4); lcd.refresh(); wait(3); } } void SavedGames::add_saved_data(SDFileSystem &sd, SavedGamesData data, N5110 &lcd){ check_open_file(sd,lcd); //opens file FILE *fp; fp = fopen("/sd/SavedGames.text", "a"); //Adda data to file if no error if(!error_){ fprintf(fp, "%d\n", data.score); fprintf(fp, "%d\n", data.lives); fprintf(fp, "%d\n", data.smart_bombs); fprintf(fp, "%d\n", data.alien_number); fclose(fp); } } bool SavedGames::get_error(){ return error_; }