Joe Body 201215898

Dependencies:   mbed

Navigation

  • From the Main Menu the A button will take you into one of the play, highscore or instructions options.
  • The B button will return you to the Main Menu from either the highscore or instruction screens, though this is prompted on screen.
  • When in the Main Menu Pot1 can be used to adjust the contrast and the volume control by the speaker is active.
  • When the game is over the B button can be used to return to the Main Menu, again this is prompted.
  • To return to the Main Menu while the game is being played the reset button must be pressed, this will not save your score or anything about the game.

In Game

  • While in the game the A button is used to shoot while you aim with the Joystick.
  • You have control over the cross while the objective of the game is to rack up as many points shooting the moving head.
  • There is a slight reload time on each shot so you are unable to spam A if you miss.
  • Once you miss 6 times the game will end and your score will be saved.
  • When hit by a falling spike the game will transition and the head will vanish.
  • 4 new spikes will spawn which you need to avoid, being hit by 1 of these will decrease your remaining miss chances by 5.
  • When the game is in this state you must avoid these spikes by tilting the device, the Joystick will have no effect.
  • The head will move progressively faster as the game goes on, make use of the clock power up by shooting it when it appears, this will slow the head down to a more manageable level hopefully helping you to reach a higher score.

Highscore

  • If you have a SD card inserted into the device the game can save your highest score.
  • A decent score is somewhere around 25.
Committer:
el18jgb
Date:
Sun May 24 11:24:57 2020 +0000
Revision:
23:0e8155320571
Parent:
22:7406068f6c59
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18jgb 14:66a1965318cb 1 #include "Menu.h"
el18jgb 14:66a1965318cb 2
el18jgb 14:66a1965318cb 3 const int curs [5][5] =
el18jgb 14:66a1965318cb 4 {
el18jgb 14:66a1965318cb 5 {0,0,1,0,0},
el18jgb 14:66a1965318cb 6 {0,0,1,0,0},
el18jgb 14:66a1965318cb 7 {1,1,0,1,1},
el18jgb 14:66a1965318cb 8 {0,0,1,0,0},
el18jgb 14:66a1965318cb 9 {0,0,1,0,0},
el18jgb 14:66a1965318cb 10 };
el18jgb 14:66a1965318cb 11
el18jgb 14:66a1965318cb 12 Menu::Menu()
el18jgb 14:66a1965318cb 13 {
el18jgb 14:66a1965318cb 14
el18jgb 14:66a1965318cb 15 }
el18jgb 14:66a1965318cb 16
el18jgb 14:66a1965318cb 17 Menu::~Menu()
el18jgb 14:66a1965318cb 18 {
el18jgb 14:66a1965318cb 19
el18jgb 14:66a1965318cb 20 }
el18jgb 14:66a1965318cb 21
el18jgb 14:66a1965318cb 22 void Menu::init()
el18jgb 14:66a1965318cb 23 {
el18jgb 14:66a1965318cb 24 option = 1;
el18jgb 14:66a1965318cb 25 _x = 1;
el18jgb 21:a0f3651f56c4 26 _y = 17;//hovers by play to begin with
el18jgb 14:66a1965318cb 27 }
el18jgb 14:66a1965318cb 28
el18jgb 21:a0f3651f56c4 29 void Menu::display(N5110 &lcd, Gamepad &pad) //main menu display
el18jgb 14:66a1965318cb 30 {
el18jgb 14:66a1965318cb 31
el18jgb 16:7c612029d9c9 32 while ( pad.A_held() == false) {
el18jgb 14:66a1965318cb 33 lcd.clear();
el18jgb 14:66a1965318cb 34 lcd.setContrast( pad.read_pot1());
el18jgb 14:66a1965318cb 35
el18jgb 14:66a1965318cb 36 lcd.printString(" Main Menu ",0,0);
el18jgb 14:66a1965318cb 37 lcd.printString(" Play ",0,2);
el18jgb 14:66a1965318cb 38 lcd.printString(" Highscore ",0,3);
el18jgb 14:66a1965318cb 39 lcd.printString(" Instructions ",0,4);
el18jgb 14:66a1965318cb 40
el18jgb 14:66a1965318cb 41 update(pad);
el18jgb 14:66a1965318cb 42 draw(lcd);
el18jgb 14:66a1965318cb 43 lcd.refresh();
el18jgb 14:66a1965318cb 44
el18jgb 14:66a1965318cb 45 }
el18jgb 14:66a1965318cb 46 wait(0.2);
el18jgb 16:7c612029d9c9 47 //return option;
el18jgb 14:66a1965318cb 48 }
el18jgb 14:66a1965318cb 49
el18jgb 14:66a1965318cb 50 void Menu::draw(N5110 &lcd)
el18jgb 14:66a1965318cb 51 {
el18jgb 21:a0f3651f56c4 52 lcd.drawSprite(_x,_y,5,5,(int*)curs); // draw a cursor for visual sellection of mode
el18jgb 14:66a1965318cb 53 }
el18jgb 14:66a1965318cb 54
el18jgb 14:66a1965318cb 55 void Menu::update(Gamepad &pad)
el18jgb 14:66a1965318cb 56 {
el18jgb 14:66a1965318cb 57
el18jgb 14:66a1965318cb 58 Direction d = pad.get_direction();
el18jgb 14:66a1965318cb 59
el18jgb 14:66a1965318cb 60 if (d == S) {
el18jgb 14:66a1965318cb 61 option += 1;
el18jgb 14:66a1965318cb 62 } else if (d == SE) {
el18jgb 14:66a1965318cb 63 option += 1;
el18jgb 21:a0f3651f56c4 64 } else if (d == SW) {// any general south
el18jgb 14:66a1965318cb 65 option += 1;
el18jgb 14:66a1965318cb 66 } else if (d == N) {
el18jgb 14:66a1965318cb 67 option -= 1;
el18jgb 14:66a1965318cb 68 } else if (d == NE) {
el18jgb 14:66a1965318cb 69 option -= 1;
el18jgb 21:a0f3651f56c4 70 } else if (d == NW) {//any general north
el18jgb 14:66a1965318cb 71 option -= 1;
el18jgb 14:66a1965318cb 72 } else {
el18jgb 14:66a1965318cb 73 option = option;
el18jgb 14:66a1965318cb 74 }
el18jgb 14:66a1965318cb 75
el18jgb 14:66a1965318cb 76 if (option == 4){
el18jgb 14:66a1965318cb 77 option = 3;
el18jgb 14:66a1965318cb 78 }
el18jgb 14:66a1965318cb 79
el18jgb 23:0e8155320571 80 if (option == 0){//despite being a 'mode' this means an option is always chosen
el18jgb 14:66a1965318cb 81 option = 1;
el18jgb 14:66a1965318cb 82 }
el18jgb 14:66a1965318cb 83
el18jgb 21:a0f3651f56c4 84 if (option == 1){//inline with play
el18jgb 14:66a1965318cb 85 _y = 17;
el18jgb 14:66a1965318cb 86 }
el18jgb 14:66a1965318cb 87
el18jgb 21:a0f3651f56c4 88 if (option == 2){//highscore with play
el18jgb 14:66a1965318cb 89 _y = 25;
el18jgb 14:66a1965318cb 90 }
el18jgb 14:66a1965318cb 91
el18jgb 21:a0f3651f56c4 92 if (option == 3){//instructions with play
el18jgb 14:66a1965318cb 93 _y = 33;
el18jgb 14:66a1965318cb 94 }
el18jgb 14:66a1965318cb 95
el18jgb 14:66a1965318cb 96 wait(0.2);
el18jgb 21:a0f3651f56c4 97 //printf("option = %d\n", option);
el18jgb 14:66a1965318cb 98 }
el18jgb 14:66a1965318cb 99
el18jgb 14:66a1965318cb 100 void Menu::instructions(N5110 &lcd, Gamepad &pad)
el18jgb 14:66a1965318cb 101 {
el18jgb 23:0e8155320571 102 while ( pad.B_held() == false) {//b held works better than pressed
el18jgb 14:66a1965318cb 103 lcd.clear();
el18jgb 14:66a1965318cb 104
el18jgb 14:66a1965318cb 105 lcd.printString(" Instructions ",0,0);
el18jgb 14:66a1965318cb 106 lcd.printString("(move cursor ",0,2);
el18jgb 14:66a1965318cb 107 lcd.printString("with Joy-Stick",0,3);
el18jgb 14:66a1965318cb 108 lcd.printString(" shoot with A)",0,4);
el18jgb 14:66a1965318cb 109 lcd.printString("return press B",0,5);
el18jgb 14:66a1965318cb 110
el18jgb 14:66a1965318cb 111 lcd.refresh();
el18jgb 14:66a1965318cb 112 }
el18jgb 14:66a1965318cb 113 wait(0.1);
el18jgb 14:66a1965318cb 114 }
el18jgb 16:7c612029d9c9 115
el18jgb 16:7c612029d9c9 116 int Menu::getmode()
el18jgb 16:7c612029d9c9 117 {
el18jgb 16:7c612029d9c9 118 return option;
el18jgb 16:7c612029d9c9 119 }
el18jgb 19:33c77517cb88 120
el18jgb 19:33c77517cb88 121 void Menu::highs_screen(N5110 &lcd, Gamepad &pad, Highscore &hs, SDFileSystem &sd)
el18jgb 19:33c77517cb88 122 {
el18jgb 22:7406068f6c59 123
el18jgb 23:0e8155320571 124 while ( pad.B_held() == false) {//b held works better than pressed
el18jgb 19:33c77517cb88 125 lcd.clear();
el18jgb 19:33c77517cb88 126
el18jgb 19:33c77517cb88 127 int value = hs.geths(sd);
el18jgb 19:33c77517cb88 128 //printf("value %d \n", value);
el18jgb 19:33c77517cb88 129 lcd.printString(" Highscore ",0,0);
el18jgb 19:33c77517cb88 130
el18jgb 19:33c77517cb88 131 char buffer1[14];
el18jgb 23:0e8155320571 132 sprintf(buffer1,"%2d",value);//prints the stored score
el18jgb 23:0e8155320571 133 lcd.printString(buffer1,34,3);
el18jgb 19:33c77517cb88 134
el18jgb 19:33c77517cb88 135 lcd.printString("return press B",0,5);
el18jgb 19:33c77517cb88 136
el18jgb 19:33c77517cb88 137 lcd.refresh();
el18jgb 19:33c77517cb88 138 }
el18jgb 19:33c77517cb88 139 wait(0.1);
el18jgb 19:33c77517cb88 140 }