Mortal Kombat Game ELEC2645

Dependencies:   mbed N5110 ShiftReg Joystick

Menu.cpp

Committer:
ozy
Date:
2021-04-13
Revision:
0:99b49fd71085
Child:
1:3bdadf6f6dbd

File content as of revision 0:99b49fd71085:

#include "Menu.h"
#include "mbed.h"


// This class is responsible for presenting the GUI of the game
Menu::Menu() {} 

void Menu::draw_logo(N5110 &lcd, int x, int y) {
    // Mortal Kombat Logo
    const int logo[17][19] =   {
    { 1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1 }, 
    { 0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0 },
    { 0,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,0,0,0 },
    { 0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0 },
    { 0,0,0,1,0,1,1,0,0,1,1,1,1,0,0,0,1,0,0 },
    { 0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,0 },
    { 0,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0 },
    { 0,0,1,0,1,1,1,0,0,0,1,1,1,1,1,0,0,1,0 },
    { 0,0,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,1,0 },
    { 0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,0 },
    { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0 },
    { 0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0 },
    { 0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0 },
    { 0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0 },
    { 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0 },
    { 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0 },
    { 1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1 },
};
// draw the MK Logo
                // (x, y, rows, cols, sprite)
    lcd.drawSprite(x,y,17,19,(int *)logo);
}

void Menu::main_menu(N5110 &lcd) {
// Printing the first menu screen
        lcd.printString("MORTAL KOMBAT",3,1);
        lcd.printString("LEEDS EDITION",3,2);
        lcd.refresh();
        draw_logo(lcd, 30, 28); // draw logo on (30,28)
        // draw menu frame using the whole dimensions of the screen
        lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); 
        lcd.refresh(); // refresh the LCD so the pixels appear
}

void Menu::created_by(N5110 &lcd) {
    lcd.clear();
    lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); 
    lcd.printString("Created by:",2,1);
    lcd.printString("OSMAN",25,2);
    lcd.printString("FADL ALI",20,3);
    lcd.printString("201337691",18,4);
    lcd.refresh();
}
void Menu::A_to_start(N5110 &lcd) {
    lcd.clear();
    lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); 
    lcd.printString(" Press A ",15,2);
    lcd.printString(" to  ",20,3);
    lcd.printString(" Start! ",15,4);
    lcd.refresh();
}

void Menu::homescreen(N5110 &lcd) {
    lcd.clear();
    // lcd.drawLine(0,46,0,0,1);
    // lcd.drawLine(84,0,84,46,1);
    lcd.printString(" Press Button ", 0, 0);
    lcd.printString("  to Select: ", 0, 1);
    lcd.printString(" A - Play", 0, 3);
    lcd.printString(" B - Tutorial", 0, 4);
    lcd.printString(" C - Options", 0, 5);
    lcd.refresh();
}

void Menu::play(N5110 &lcd) {
    lcd.printString("Play", 0, 0);
}

void Menu::tutorial(N5110 &lcd) {
    lcd.printString("Tutorial", 0, 0);
}

void Menu::options_menu(N5110 &lcd) {
    lcd.printString("Options", 0, 0);
}
/*
void Menu::select_item(char button) { // using case switching for each screen
  switch (button) {
    case 'A':
      play(lcd);
      break;
    case 'B':
      tutorial(lcd);
      break;
    case 'C':
      options_menu(lcd);
      break;
    default:
      homescreen(lcd); 
      break;
  }
}
*/