![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mortal Kombat Game ELEC2645
Dependencies: mbed N5110 ShiftReg Joystick
Menu.cpp@0:99b49fd71085, 2021-04-13 (annotated)
- Committer:
- ozy
- Date:
- Tue Apr 13 10:06:02 2021 +0000
- Revision:
- 0:99b49fd71085
- Child:
- 1:3bdadf6f6dbd
Sprite moving and Debugging menu class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ozy | 0:99b49fd71085 | 1 | #include "Menu.h" |
ozy | 0:99b49fd71085 | 2 | #include "mbed.h" |
ozy | 0:99b49fd71085 | 3 | |
ozy | 0:99b49fd71085 | 4 | |
ozy | 0:99b49fd71085 | 5 | // This class is responsible for presenting the GUI of the game |
ozy | 0:99b49fd71085 | 6 | Menu::Menu() {} |
ozy | 0:99b49fd71085 | 7 | |
ozy | 0:99b49fd71085 | 8 | void Menu::draw_logo(N5110 &lcd, int x, int y) { |
ozy | 0:99b49fd71085 | 9 | // Mortal Kombat Logo |
ozy | 0:99b49fd71085 | 10 | const int logo[17][19] = { |
ozy | 0:99b49fd71085 | 11 | { 1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 12 | { 0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 13 | { 0,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 14 | { 0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 15 | { 0,0,0,1,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0 }, |
ozy | 0:99b49fd71085 | 16 | { 0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 17 | { 0,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 18 | { 0,0,1,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 19 | { 0,0,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,1,0 }, |
ozy | 0:99b49fd71085 | 20 | { 0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 21 | { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0 }, |
ozy | 0:99b49fd71085 | 22 | { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0 }, |
ozy | 0:99b49fd71085 | 23 | { 0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0 }, |
ozy | 0:99b49fd71085 | 24 | { 0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0 }, |
ozy | 0:99b49fd71085 | 25 | { 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 26 | { 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0 }, |
ozy | 0:99b49fd71085 | 27 | { 1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1 }, |
ozy | 0:99b49fd71085 | 28 | }; |
ozy | 0:99b49fd71085 | 29 | // draw the MK Logo |
ozy | 0:99b49fd71085 | 30 | // (x, y, rows, cols, sprite) |
ozy | 0:99b49fd71085 | 31 | lcd.drawSprite(x,y,17,19,(int *)logo); |
ozy | 0:99b49fd71085 | 32 | } |
ozy | 0:99b49fd71085 | 33 | |
ozy | 0:99b49fd71085 | 34 | void Menu::main_menu(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 35 | // Printing the first menu screen |
ozy | 0:99b49fd71085 | 36 | lcd.printString("MORTAL KOMBAT",3,1); |
ozy | 0:99b49fd71085 | 37 | lcd.printString("LEEDS EDITION",3,2); |
ozy | 0:99b49fd71085 | 38 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 39 | draw_logo(lcd, 30, 28); // draw logo on (30,28) |
ozy | 0:99b49fd71085 | 40 | // draw menu frame using the whole dimensions of the screen |
ozy | 0:99b49fd71085 | 41 | lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); |
ozy | 0:99b49fd71085 | 42 | lcd.refresh(); // refresh the LCD so the pixels appear |
ozy | 0:99b49fd71085 | 43 | } |
ozy | 0:99b49fd71085 | 44 | |
ozy | 0:99b49fd71085 | 45 | void Menu::created_by(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 46 | lcd.clear(); |
ozy | 0:99b49fd71085 | 47 | lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); |
ozy | 0:99b49fd71085 | 48 | lcd.printString("Created by:",2,1); |
ozy | 0:99b49fd71085 | 49 | lcd.printString("OSMAN",25,2); |
ozy | 0:99b49fd71085 | 50 | lcd.printString("FADL ALI",20,3); |
ozy | 0:99b49fd71085 | 51 | lcd.printString("201337691",18,4); |
ozy | 0:99b49fd71085 | 52 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 53 | } |
ozy | 0:99b49fd71085 | 54 | void Menu::A_to_start(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 55 | lcd.clear(); |
ozy | 0:99b49fd71085 | 56 | lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); |
ozy | 0:99b49fd71085 | 57 | lcd.printString(" Press A ",15,2); |
ozy | 0:99b49fd71085 | 58 | lcd.printString(" to ",20,3); |
ozy | 0:99b49fd71085 | 59 | lcd.printString(" Start! ",15,4); |
ozy | 0:99b49fd71085 | 60 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 61 | } |
ozy | 0:99b49fd71085 | 62 | |
ozy | 0:99b49fd71085 | 63 | void Menu::homescreen(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 64 | lcd.clear(); |
ozy | 0:99b49fd71085 | 65 | // lcd.drawLine(0,46,0,0,1); |
ozy | 0:99b49fd71085 | 66 | // lcd.drawLine(84,0,84,46,1); |
ozy | 0:99b49fd71085 | 67 | lcd.printString(" Press Button ", 0, 0); |
ozy | 0:99b49fd71085 | 68 | lcd.printString(" to Select: ", 0, 1); |
ozy | 0:99b49fd71085 | 69 | lcd.printString(" A - Play", 0, 3); |
ozy | 0:99b49fd71085 | 70 | lcd.printString(" B - Tutorial", 0, 4); |
ozy | 0:99b49fd71085 | 71 | lcd.printString(" C - Options", 0, 5); |
ozy | 0:99b49fd71085 | 72 | lcd.refresh(); |
ozy | 0:99b49fd71085 | 73 | } |
ozy | 0:99b49fd71085 | 74 | |
ozy | 0:99b49fd71085 | 75 | void Menu::play(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 76 | lcd.printString("Play", 0, 0); |
ozy | 0:99b49fd71085 | 77 | } |
ozy | 0:99b49fd71085 | 78 | |
ozy | 0:99b49fd71085 | 79 | void Menu::tutorial(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 80 | lcd.printString("Tutorial", 0, 0); |
ozy | 0:99b49fd71085 | 81 | } |
ozy | 0:99b49fd71085 | 82 | |
ozy | 0:99b49fd71085 | 83 | void Menu::options_menu(N5110 &lcd) { |
ozy | 0:99b49fd71085 | 84 | lcd.printString("Options", 0, 0); |
ozy | 0:99b49fd71085 | 85 | } |
ozy | 0:99b49fd71085 | 86 | /* |
ozy | 0:99b49fd71085 | 87 | void Menu::select_item(char button) { // using case switching for each screen |
ozy | 0:99b49fd71085 | 88 | switch (button) { |
ozy | 0:99b49fd71085 | 89 | case 'A': |
ozy | 0:99b49fd71085 | 90 | play(lcd); |
ozy | 0:99b49fd71085 | 91 | break; |
ozy | 0:99b49fd71085 | 92 | case 'B': |
ozy | 0:99b49fd71085 | 93 | tutorial(lcd); |
ozy | 0:99b49fd71085 | 94 | break; |
ozy | 0:99b49fd71085 | 95 | case 'C': |
ozy | 0:99b49fd71085 | 96 | options_menu(lcd); |
ozy | 0:99b49fd71085 | 97 | break; |
ozy | 0:99b49fd71085 | 98 | default: |
ozy | 0:99b49fd71085 | 99 | homescreen(lcd); |
ozy | 0:99b49fd71085 | 100 | break; |
ozy | 0:99b49fd71085 | 101 | } |
ozy | 0:99b49fd71085 | 102 | } |
ozy | 0:99b49fd71085 | 103 | */ |