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:
Fri May 22 13:02:26 2020 +0000
Revision:
69:753ba27325ce
Parent:
68:bb1650c657ef
Child:
72:e7492591307e
Finished settings class and added it to into game engine.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 40:71f947254fda 1 #include "Menu.h"
evanso 40:71f947254fda 2
evanso 69:753ba27325ce 3 const char menu_part_names[3][12] = {
evanso 40:71f947254fda 4 {"Play"},
evanso 40:71f947254fda 5 {"Settings"},
evanso 40:71f947254fda 6 {"Saved Games"},
evanso 40:71f947254fda 7 };
evanso 40:71f947254fda 8
evanso 40:71f947254fda 9 // Defining scroll_order states for scroll_order FSM
evanso 40:71f947254fda 10 scroll_order menu_fsm[3] = {
evanso 41:5959256f4aab 11 {settings, saved_games},
evanso 41:5959256f4aab 12 {saved_games, play},
evanso 40:71f947254fda 13 {play, settings},
evanso 40:71f947254fda 14 };
evanso 40:71f947254fda 15
evanso 40:71f947254fda 16 Menu::Menu() {
evanso 40:71f947254fda 17
evanso 40:71f947254fda 18 }
evanso 40:71f947254fda 19
evanso 40:71f947254fda 20 Menu::~Menu() {
evanso 40:71f947254fda 21
evanso 40:71f947254fda 22 }
evanso 40:71f947254fda 23
evanso 40:71f947254fda 24 void Menu::init() {
evanso 40:71f947254fda 25 current_menu_part_ = main_menu;
evanso 40:71f947254fda 26 displayed_menu_part_ = play;
evanso 40:71f947254fda 27 }
evanso 40:71f947254fda 28
evanso 40:71f947254fda 29 void Menu::draw_part(N5110 &lcd) {
evanso 40:71f947254fda 30 // Prints the menu part that should be displayed in the centre
evanso 40:71f947254fda 31 if(displayed_menu_part_ == play){
evanso 40:71f947254fda 32 lcd.printString(menu_part_names[displayed_menu_part_],30 ,4);
evanso 40:71f947254fda 33 }else if(displayed_menu_part_ == settings){
evanso 40:71f947254fda 34 lcd.printString(menu_part_names[displayed_menu_part_],18 ,4);
evanso 41:5959256f4aab 35 }else if(displayed_menu_part_ == saved_games){
evanso 40:71f947254fda 36 lcd.printString(menu_part_names[displayed_menu_part_],9 ,4);
evanso 40:71f947254fda 37 }
evanso 40:71f947254fda 38
evanso 40:71f947254fda 39 lcd.drawSprite(39, 26, 3, 5, (int *)arrow_up);
evanso 40:71f947254fda 40 lcd.drawSprite(39, 42, 3, 5, (int *)arrow_down);
evanso 68:bb1650c657ef 41 title_screen(lcd);
evanso 40:71f947254fda 42
evanso 40:71f947254fda 43 #ifdef MENU_DEBUG
evanso 40:71f947254fda 44 printf("displayed_menu_part_ = %d\n",displayed_menu_part_);
evanso 40:71f947254fda 45 printf("current_menu_part_ = %d\n", current_menu_part_);
evanso 40:71f947254fda 46 #endif
evanso 40:71f947254fda 47 }
evanso 40:71f947254fda 48
evanso 65:daa792a09e1f 49 void Menu::menu_scroll(Direction d_) {
evanso 69:753ba27325ce 50 //printf("displayed_menu_part_ %d\n",displayed_menu_part_);
evanso 69:753ba27325ce 51 //printf("d = %d\n",d_);
evanso 40:71f947254fda 52 // Changes displayed manu part depending on joystick input
evanso 40:71f947254fda 53 if (d_ == N || d_ == NE || d_ == NW ) {
evanso 40:71f947254fda 54 displayed_menu_part_ = menu_fsm[displayed_menu_part_].part_next;
evanso 40:71f947254fda 55 } else if (d_ == S || d_ == SW || d_ == SE) {
evanso 40:71f947254fda 56 displayed_menu_part_ = menu_fsm[displayed_menu_part_].part_next;
evanso 40:71f947254fda 57 displayed_menu_part_ = menu_fsm[displayed_menu_part_].part_next;
evanso 40:71f947254fda 58 }
evanso 43:d43759dbddb9 59 wait(0.15);
evanso 40:71f947254fda 60 }
evanso 40:71f947254fda 61
evanso 65:daa792a09e1f 62 void Menu::select_part(bool pressed) {
evanso 65:daa792a09e1f 63 if (pressed) {
evanso 40:71f947254fda 64 current_menu_part_ = displayed_menu_part_;
evanso 40:71f947254fda 65 } else {
evanso 40:71f947254fda 66 current_menu_part_ = main_menu;
evanso 40:71f947254fda 67 }
evanso 65:daa792a09e1f 68 wait(0.035);
evanso 40:71f947254fda 69 }
evanso 41:5959256f4aab 70
evanso 41:5959256f4aab 71 MenuParts Menu::get_current_menu_part(){
evanso 41:5959256f4aab 72 return current_menu_part_;
evanso 41:5959256f4aab 73 }
evanso 68:bb1650c657ef 74
evanso 68:bb1650c657ef 75 void Menu::title_screen(N5110 &lcd) {
evanso 68:bb1650c657ef 76 lcd.drawSprite(5, 8, 10, 8, (int *)title_screen_d); //D
evanso 68:bb1650c657ef 77 lcd.drawSprite(15, 8, 10, 7, (int *)title_screen_e); //E
evanso 68:bb1650c657ef 78 lcd.drawSprite(24, 8, 10, 7, (int *)title_screen_f); //F
evanso 68:bb1650c657ef 79 lcd.drawSprite(33, 8, 10, 7, (int *)title_screen_e); //E
evanso 68:bb1650c657ef 80 lcd.drawSprite(42, 8, 10, 7, (int *)title_screen_n); //N
evanso 68:bb1650c657ef 81 lcd.drawSprite(51, 8, 10, 8, (int *)title_screen_d); //D
evanso 68:bb1650c657ef 82 lcd.drawSprite(61, 8, 10, 7, (int *)title_screen_e); //E
evanso 68:bb1650c657ef 83 lcd.drawSprite(70, 8, 10, 8, (int *)title_screen_r); //R
evanso 68:bb1650c657ef 84 }
evanso 40:71f947254fda 85