Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Committer:
adambakerwa
Date:
Sun Mar 24 22:47:33 2019 +0000
Revision:
12:1253afc5d536
Parent:
11:dcb38924d96b
Child:
13:35a459a33bbd
All still animations complete!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
adambakerwa 1:a3cce487dffe 1 #include "mbed.h"
adambakerwa 1:a3cce487dffe 2 #include "Gamepad.h"
adambakerwa 1:a3cce487dffe 3 #include "N5110.h"
adambakerwa 1:a3cce487dffe 4 #include "Runner.h"
adambakerwa 6:cef9c2853315 5 #include "Levels.h"
adambakerwa 9:ddeafaadf984 6 #include "Animation.h"
adambakerwa 1:a3cce487dffe 7
adambakerwa 1:a3cce487dffe 8 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
adambakerwa 1:a3cce487dffe 9 Gamepad pad;
adambakerwa 1:a3cce487dffe 10 Runner runner;
adambakerwa 9:ddeafaadf984 11 Animation ani;
adambakerwa 1:a3cce487dffe 12
adambakerwa 6:cef9c2853315 13
adambakerwa 1:a3cce487dffe 14 int main() {
adambakerwa 1:a3cce487dffe 15
adambakerwa 12:1253afc5d536 16 int fps = 8;
adambakerwa 1:a3cce487dffe 17
adambakerwa 1:a3cce487dffe 18 pad.init();
adambakerwa 1:a3cce487dffe 19 lcd.init();
adambakerwa 1:a3cce487dffe 20
adambakerwa 1:a3cce487dffe 21 Move move;
adambakerwa 1:a3cce487dffe 22
adambakerwa 1:a3cce487dffe 23 move = runner.init(move);
adambakerwa 1:a3cce487dffe 24
adambakerwa 1:a3cce487dffe 25 while(1) {
adambakerwa 1:a3cce487dffe 26
adambakerwa 1:a3cce487dffe 27 lcd.clear();
adambakerwa 2:1ad390d81d81 28
adambakerwa 4:cf765fff4e0e 29 float speed = runner.getSpeed(pad);
adambakerwa 1:a3cce487dffe 30
adambakerwa 12:1253afc5d536 31 //runner.runnerState(move, lcd, speed);
adambakerwa 11:dcb38924d96b 32
adambakerwa 11:dcb38924d96b 33 move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen
adambakerwa 11:dcb38924d96b 34
adambakerwa 11:dcb38924d96b 35 runner.whatLevel(move, lcd);
adambakerwa 11:dcb38924d96b 36
adambakerwa 4:cf765fff4e0e 37 move = runner.buttonPress(move, lcd, pad);
adambakerwa 4:cf765fff4e0e 38
adambakerwa 4:cf765fff4e0e 39 move = runner.jump(move, lcd);
adambakerwa 4:cf765fff4e0e 40
adambakerwa 5:37b37f48e8bf 41 move = runner.wallJumpL(move, lcd, speed);
adambakerwa 5:37b37f48e8bf 42
adambakerwa 5:37b37f48e8bf 43 move = runner.wallJumpR(move, lcd, speed);
adambakerwa 4:cf765fff4e0e 44
adambakerwa 3:c1f4968111d7 45 move = runner.runLeft(move, lcd, speed);
adambakerwa 3:c1f4968111d7 46
adambakerwa 3:c1f4968111d7 47 move = runner.runRight(move, lcd, speed);
adambakerwa 2:1ad390d81d81 48
adambakerwa 10:a37a4d2c09e7 49 move = runner.fall(move, lcd);
adambakerwa 2:1ad390d81d81 50
adambakerwa 12:1253afc5d536 51
adambakerwa 11:dcb38924d96b 52 runner.runnerState(move, lcd, speed); //what state runner is in (must come after next level
adambakerwa 6:cef9c2853315 53
adambakerwa 12:1253afc5d536 54 runner.whatLevel(move, lcd); // call level
adambakerwa 6:cef9c2853315 55
adambakerwa 7:66ea4d394fea 56 /**char buffer[14];
adambakerwa 7:66ea4d394fea 57 sprintf(buffer,"%i",move.l);
adambakerwa 2:1ad390d81d81 58 lcd.printString(buffer,0,1);
adambakerwa 7:66ea4d394fea 59 */
adambakerwa 12:1253afc5d536 60 int test;
adambakerwa 12:1253afc5d536 61 if (ani.pixelsLeft(move.x, move.y, lcd) == true) {
adambakerwa 12:1253afc5d536 62 test = 1;
adambakerwa 12:1253afc5d536 63 } else {
adambakerwa 12:1253afc5d536 64 test = 0;
adambakerwa 12:1253afc5d536 65 }
adambakerwa 11:dcb38924d96b 66
adambakerwa 3:c1f4968111d7 67 char buffer1[14];
adambakerwa 12:1253afc5d536 68 sprintf(buffer1,"%i",test);
adambakerwa 3:c1f4968111d7 69 lcd.printString(buffer1,0,0);
adambakerwa 2:1ad390d81d81 70
adambakerwa 5:37b37f48e8bf 71
adambakerwa 1:a3cce487dffe 72 lcd.refresh();
adambakerwa 1:a3cce487dffe 73
adambakerwa 1:a3cce487dffe 74 wait(1.0f/fps);
adambakerwa 1:a3cce487dffe 75
adambakerwa 1:a3cce487dffe 76 }
adambakerwa 1:a3cce487dffe 77 }
adambakerwa 1:a3cce487dffe 78
adambakerwa 1:a3cce487dffe 79
adambakerwa 2:1ad390d81d81 80