test 1 doc

Dependencies:   mbed Gamepad2

main.cpp

Committer:
joebarhouch
Date:
2020-05-18
Revision:
3:e4e1cbf750b6
Parent:
2:f22cb01c43bc
Child:
4:cf5088ace087

File content as of revision 3:e4e1cbf750b6:

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
2019/20

Name: Joe Barhouch
Username: el18jb
Student ID Number: 201291584
*/

// includes
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Bitmap.h"
#include "Player.h"
#include "Engine.h"

// objects
Gamepad pad;
N5110 lcd;
Player player;
Engine engine;

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



// function prototypes
void init();
void display();

int main()
{


    init();

    int fps = 10;  // frames per second
    display();  // first draw the initial frame
    wait(1.0f/fps);  // and wait for one frame period

    // game loop - read input, update the game state and render the display
    while (1) {
        lcd.setContrast( pad.read_pot1());
        engine.read_input(pad);
        engine.update(pad);
        display();
        wait(1.0f/fps);
    }
}

void init()
{
    lcd.init();
    pad.init();
    engine.init();
}

void display()
{
    lcd.clear();
    engine.draw(lcd);
    lcd.refresh();
}