Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

main.cpp

Committer:
adambakerwa
Date:
2019-03-24
Revision:
12:1253afc5d536
Parent:
11:dcb38924d96b
Child:
13:35a459a33bbd

File content as of revision 12:1253afc5d536:

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

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


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

        lcd.clear();
        
        float speed = runner.getSpeed(pad);
        
        //runner.runnerState(move, lcd, speed);

        move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen 
                
        runner.whatLevel(move, lcd);
                         
        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);
        
        
        runner.runnerState(move, lcd, speed); //what state runner is in (must come after next level
    
        runner.whatLevel(move, lcd); // call level 
        
        /**char buffer[14];
        sprintf(buffer,"%i",move.l);
        lcd.printString(buffer,0,1);
        */
        int test;
        if (ani.pixelsLeft(move.x, move.y, lcd) == true) {
            test = 1;
        } else {
            test = 0;
        }
    
        char buffer1[14];
        sprintf(buffer1,"%i",test);
        lcd.printString(buffer1,0,0);
        
        
        lcd.refresh();
        
        wait(1.0f/fps);
        
    }
}