Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Committer:
adambakerwa
Date:
Sun Mar 24 18:37:12 2019 +0000
Revision:
10:a37a4d2c09e7
Parent:
9:ddeafaadf984
Child:
11:dcb38924d96b
Testing collision possibilities

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 10:a37a4d2c09e7 16 int fps = 12;
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 9:ddeafaadf984 29 //lcd.drawCircle(move.x,move.y,3,FILL_BLACK);
adambakerwa 9:ddeafaadf984 30 ani.standing(move.x, move.y, lcd);
adambakerwa 9:ddeafaadf984 31
adambakerwa 8:44678962ec01 32
adambakerwa 7:66ea4d394fea 33 move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen
adambakerwa 6:cef9c2853315 34
adambakerwa 7:66ea4d394fea 35 runner.whatLevel(move, lcd);
adambakerwa 1:a3cce487dffe 36
adambakerwa 4:cf765fff4e0e 37 float speed = runner.getSpeed(pad);
adambakerwa 1:a3cce487dffe 38
adambakerwa 4:cf765fff4e0e 39 move = runner.buttonPress(move, lcd, pad);
adambakerwa 4:cf765fff4e0e 40
adambakerwa 4:cf765fff4e0e 41 move = runner.jump(move, lcd);
adambakerwa 4:cf765fff4e0e 42
adambakerwa 5:37b37f48e8bf 43 move = runner.wallJumpL(move, lcd, speed);
adambakerwa 5:37b37f48e8bf 44
adambakerwa 5:37b37f48e8bf 45 move = runner.wallJumpR(move, lcd, speed);
adambakerwa 4:cf765fff4e0e 46
adambakerwa 3:c1f4968111d7 47 move = runner.runLeft(move, lcd, speed);
adambakerwa 3:c1f4968111d7 48
adambakerwa 3:c1f4968111d7 49 move = runner.runRight(move, lcd, speed);
adambakerwa 2:1ad390d81d81 50
adambakerwa 10:a37a4d2c09e7 51 move = runner.fall(move, lcd);
adambakerwa 2:1ad390d81d81 52
adambakerwa 6:cef9c2853315 53
adambakerwa 6:cef9c2853315 54
adambakerwa 7:66ea4d394fea 55 /**char buffer[14];
adambakerwa 7:66ea4d394fea 56 sprintf(buffer,"%i",move.l);
adambakerwa 2:1ad390d81d81 57 lcd.printString(buffer,0,1);
adambakerwa 7:66ea4d394fea 58 */
adambakerwa 3:c1f4968111d7 59 char buffer1[14];
adambakerwa 9:ddeafaadf984 60 sprintf(buffer1,"%i",move.gp);
adambakerwa 3:c1f4968111d7 61 lcd.printString(buffer1,0,0);
adambakerwa 2:1ad390d81d81 62
adambakerwa 5:37b37f48e8bf 63
adambakerwa 1:a3cce487dffe 64 lcd.refresh();
adambakerwa 1:a3cce487dffe 65
adambakerwa 1:a3cce487dffe 66 wait(1.0f/fps);
adambakerwa 1:a3cce487dffe 67
adambakerwa 1:a3cce487dffe 68 }
adambakerwa 1:a3cce487dffe 69 }
adambakerwa 1:a3cce487dffe 70
adambakerwa 1:a3cce487dffe 71
adambakerwa 2:1ad390d81d81 72