Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

main.cpp

Committer:
adambakerwa
Date:
2019-03-22
Revision:
7:66ea4d394fea
Parent:
6:cef9c2853315
Child:
8:44678962ec01

File content as of revision 7:66ea4d394fea:

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


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


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

        lcd.clear();
        
        lcd.drawCircle(move.x,move.y,3,FILL_BLACK);

        move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen 
        
        runner.whatLevel(move, lcd);
        
        float speed = runner.getSpeed(pad);
        
        move = runner.buttonPress(move, lcd, pad);
        
        move = runner.jump(move, lcd);
        
        move = runner.wallJumpL(move, lcd, speed); 
        
        move = runner.wallJumpR(move, lcd, speed);            
               
        move = runner.runLeft(move, lcd, speed);
        
        move = runner.runRight(move, lcd, speed);
        
    
 
        move = runner.fall(move, lcd);
        
    
        
        /**char buffer[14];
        sprintf(buffer,"%i",move.l);
        lcd.printString(buffer,0,1);
        */
        char buffer1[14];
        sprintf(buffer1,"%i",move.l);
        lcd.printString(buffer1,0,0);
        
        
        lcd.refresh();
        
        wait(1.0f/fps);
        
    }
}