Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

main.cpp

Committer:
AhmedPlaymaker
Date:
2019-03-23
Revision:
6:3ffab44ed49c
Parent:
3:fbb1fa853f09
Child:
7:48ba87cd79b5

File content as of revision 6:3ffab44ed49c:

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Ahmed Nomaan Adamjee
Username: AhmedPlaymaker
Student ID Number: 201161436
Date:
*/

///////// pre-processor directives ////////
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "FXOS8700CQ.h"
#include "StartScreen.h"
//#include "SnakevsBlock.h"

/////////////// structs /////////////////
struct UserInput {
    Direction d;
    float mag;
};

/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
FXOS8700CQ device(I2C_SDA,I2C_SCL);
StartScreen _start;
//SnakevsBlock game;

///////////// prototypes ///////////////
void init();
void refresh_game();
//void update_game(UserInput input);

//Constants//
int fps = 7;  // frames per second

///////////// MAIN ////////////////
int main()
{
    
    init();
    _start.screen_saver(lcd, pad);
    _start.instruct(lcd, pad);
    _start.info(lcd, pad);
    _start.menu_screen1(lcd, pad);
     // start the game
    refresh_game();
    wait(1.0f/fps);  

    // snakeVSblock - detect input respect to the menu options, and update data and refresh screen
    while (1) {
        
        //game.read_input(pad);
        //game.update(pad);
        refresh_game();
        
        wait(1.0f/fps);
                
    }
}

void init()
{
    // need to initialise LCD and Gamepad 
    lcd.init();
    pad.init();
    pad.tone(1000.0,0.1);
    //game.init();

}

void refresh_game()
{
    lcd.clear();  
    //game.draw(lcd, pad);
    lcd.refresh();

}