Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Committer:
adambakerwa
Date:
Fri Mar 22 22:05:03 2019 +0000
Revision:
7:66ea4d394fea
Parent:
6:cef9c2853315
Child:
8:44678962ec01
level change working

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 6:cef9c2853315 6
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 1:a3cce487dffe 11
adambakerwa 6:cef9c2853315 12
adambakerwa 1:a3cce487dffe 13 int main() {
adambakerwa 1:a3cce487dffe 14
adambakerwa 2:1ad390d81d81 15 int fps = 12;
adambakerwa 1:a3cce487dffe 16
adambakerwa 1:a3cce487dffe 17 pad.init();
adambakerwa 1:a3cce487dffe 18 lcd.init();
adambakerwa 1:a3cce487dffe 19
adambakerwa 1:a3cce487dffe 20 Move move;
adambakerwa 1:a3cce487dffe 21
adambakerwa 1:a3cce487dffe 22 move = runner.init(move);
adambakerwa 1:a3cce487dffe 23
adambakerwa 1:a3cce487dffe 24 while(1) {
adambakerwa 1:a3cce487dffe 25
adambakerwa 1:a3cce487dffe 26 lcd.clear();
adambakerwa 2:1ad390d81d81 27
adambakerwa 1:a3cce487dffe 28 lcd.drawCircle(move.x,move.y,3,FILL_BLACK);
adambakerwa 6:cef9c2853315 29
adambakerwa 7:66ea4d394fea 30 move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen
adambakerwa 6:cef9c2853315 31
adambakerwa 7:66ea4d394fea 32 runner.whatLevel(move, lcd);
adambakerwa 1:a3cce487dffe 33
adambakerwa 4:cf765fff4e0e 34 float speed = runner.getSpeed(pad);
adambakerwa 1:a3cce487dffe 35
adambakerwa 4:cf765fff4e0e 36 move = runner.buttonPress(move, lcd, pad);
adambakerwa 4:cf765fff4e0e 37
adambakerwa 4:cf765fff4e0e 38 move = runner.jump(move, lcd);
adambakerwa 4:cf765fff4e0e 39
adambakerwa 5:37b37f48e8bf 40 move = runner.wallJumpL(move, lcd, speed);
adambakerwa 5:37b37f48e8bf 41
adambakerwa 5:37b37f48e8bf 42 move = runner.wallJumpR(move, lcd, speed);
adambakerwa 4:cf765fff4e0e 43
adambakerwa 3:c1f4968111d7 44 move = runner.runLeft(move, lcd, speed);
adambakerwa 3:c1f4968111d7 45
adambakerwa 3:c1f4968111d7 46 move = runner.runRight(move, lcd, speed);
adambakerwa 6:cef9c2853315 47
adambakerwa 6:cef9c2853315 48
adambakerwa 2:1ad390d81d81 49
adambakerwa 4:cf765fff4e0e 50 move = runner.fall(move, lcd);
adambakerwa 2:1ad390d81d81 51
adambakerwa 6:cef9c2853315 52
adambakerwa 6:cef9c2853315 53
adambakerwa 7:66ea4d394fea 54 /**char buffer[14];
adambakerwa 7:66ea4d394fea 55 sprintf(buffer,"%i",move.l);
adambakerwa 2:1ad390d81d81 56 lcd.printString(buffer,0,1);
adambakerwa 7:66ea4d394fea 57 */
adambakerwa 3:c1f4968111d7 58 char buffer1[14];
adambakerwa 7:66ea4d394fea 59 sprintf(buffer1,"%i",move.l);
adambakerwa 3:c1f4968111d7 60 lcd.printString(buffer1,0,0);
adambakerwa 2:1ad390d81d81 61
adambakerwa 5:37b37f48e8bf 62
adambakerwa 1:a3cce487dffe 63 lcd.refresh();
adambakerwa 1:a3cce487dffe 64
adambakerwa 1:a3cce487dffe 65 wait(1.0f/fps);
adambakerwa 1:a3cce487dffe 66
adambakerwa 1:a3cce487dffe 67 }
adambakerwa 1:a3cce487dffe 68 }
adambakerwa 1:a3cce487dffe 69
adambakerwa 1:a3cce487dffe 70
adambakerwa 2:1ad390d81d81 71