Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

main.cpp

Committer:
adambakerwa
Date:
2019-03-21
Revision:
2:1ad390d81d81
Parent:
1:a3cce487dffe
Child:
3:c1f4968111d7

File content as of revision 2:1ad390d81d81:

#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Runner.h"

N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Runner runner;

int main() {
    
    int fps = 12;
    
    pad.init();
    lcd.init();
    
    Move move;
    float speed = 0;
    
    move = runner.init(move);
        
    while(1) {

        lcd.clear();

        lcd.drawLine(0,40,84,40,1);
        
        if (pad.check_event(Gamepad::A_PRESSED) && lcd.getPixel(move.x,move.y+4)) {
            move.j++;
            } 
        
        lcd.drawCircle(move.x,move.y,3,FILL_BLACK);
        
        Vector2D coord = pad.get_coord();
        float speed = coord.x;
        
        //move = runner.runStop(move, lcd, speed);

 
        move = runner.fallJump(move, lcd);
        
        char buffer[14];
        sprintf(buffer,"x = %f",speed);
        lcd.printString(buffer,0,1);
        
        lcd.refresh();
        
        wait(1.0f/fps);
        
    }
}