A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.

Dependencies:   ConfigFile N5110 PowerControl beep mbed

main.cpp

Committer:
el13drt
Date:
2015-04-17
Revision:
13:a1b3a373c5a4
Parent:
12:eedda6554615
Child:
14:c2c969e1c6e8

File content as of revision 13:a1b3a373c5a4:

/**
@file main.cpp
@brief Program implementation
*/

#include "mbed.h"
#include "N5110.h"
#include "beep.h"
#include "tower.h"

#include <ctime>
#include <cstdlib>

int main()
{
    ledR = 1;//power LED on

    randomise();

    calibrateJoystick();//get centred values of joystick
    pollJoystick.attach(&updateJoystick,1.0/10.0);//read joystick 10 times per second

    lcd.init();//initialise screen
    welcome();//welcome screen
    lcd.clear();//clear pixels

    int exitFlag = 0;//exit flag
    int mainOption = 0;//counter for main menu
    int exitOption = 0;//counter for exit menu
    int option = 0;//counter for options menu
    int subOption = 0;//counter for sub options menu
    int fxOption = 0;//counter for Sound FX menu

    while(1) {
        drawMainMenu();//draws main menu
        mainMenu(mainOption);//presents main menu options

        // if 'Play Game' selected
        if ((mainOption == 0)&&(buttonA == 1)) {
            game(exitFlag, exitOption);//actual game
        }
        // if 'Scores' selected
        if((mainOption == 1)&&(buttonA == 1)) {
            scores();
        }
        // if 'option' selected
        if((mainOption == 2)&&(buttonA == 1)) {
            optionsMenu(option, subOption, fxOption);
        }
    }
}