ELEC2645 (2017/18) / Mbed OS el16ajm

Menu/Menu.cpp

Committer:
Andrew_M
Date:
2018-05-06
Revision:
9:fe86ddbf7799
Parent:
8:9d01fd4a63ad
Child:
10:279d3775d52c

File content as of revision 9:fe86ddbf7799:

#include "Menu.h"

// nothing doing in the constructor and destructor
Menu::Menu()
{

}

Menu::~Menu()
{

}

void Menu::init()
{
    _start = false;

    _selection = 1;
}

void Menu::update()
{
    if (_d == N && _selection > 1) { //checks the menu arrow location
        _selection -= 1;
    } else if (_d == S && _selection < 3) {
        _selection += 1;
    }


}

void Menu::read_input(Gamepad &pad)
{
    _d = pad.get_direction();
}

void Menu::draw(N5110 &lcd)
{
    lcd.printString("  Start",0,1);
    lcd.printString("  Level Select",0,2);
    lcd.printString("  Difficulty",0,3);

    lcd.printString(" >",0,_selection);
}

bool Menu::started()
{
    return _start;
}