Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Committer:
adambakerwa
Date:
Sat Mar 23 12:01:20 2019 +0000
Revision:
8:44678962ec01
Parent:
7:66ea4d394fea
Child:
9:ddeafaadf984
Animation class created

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 8:44678962ec01 29 /**
adambakerwa 8:44678962ec01 30 const int fueltank[14][20] = {
adambakerwa 8:44678962ec01 31 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
adambakerwa 8:44678962ec01 32 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
adambakerwa 8:44678962ec01 33 { 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1},
adambakerwa 8:44678962ec01 34 { 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1},
adambakerwa 8:44678962ec01 35 { 0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0},
adambakerwa 8:44678962ec01 36 { 0,0,0,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,0},
adambakerwa 8:44678962ec01 37 { 0,0,0,1,0,0,1,0,0,0,0,1,0,1,1,0,1,1,0,0},
adambakerwa 8:44678962ec01 38 { 0,0,0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,1,1,0},
adambakerwa 8:44678962ec01 39 { 0,0,0,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,0},
adambakerwa 8:44678962ec01 40 { 0,0,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0},
adambakerwa 8:44678962ec01 41 { 0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,0},
adambakerwa 8:44678962ec01 42 { 0,0,0,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0},
adambakerwa 8:44678962ec01 43 { 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0},
adambakerwa 8:44678962ec01 44 { 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
adambakerwa 8:44678962ec01 45 };
adambakerwa 8:44678962ec01 46
adambakerwa 8:44678962ec01 47 lcd.drawSprite(x,y,14,20,(int *)fueltank);
adambakerwa 8:44678962ec01 48 */
adambakerwa 8:44678962ec01 49
adambakerwa 8:44678962ec01 50
adambakerwa 8:44678962ec01 51
adambakerwa 7:66ea4d394fea 52 move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen
adambakerwa 6:cef9c2853315 53
adambakerwa 7:66ea4d394fea 54 runner.whatLevel(move, lcd);
adambakerwa 1:a3cce487dffe 55
adambakerwa 4:cf765fff4e0e 56 float speed = runner.getSpeed(pad);
adambakerwa 1:a3cce487dffe 57
adambakerwa 4:cf765fff4e0e 58 move = runner.buttonPress(move, lcd, pad);
adambakerwa 4:cf765fff4e0e 59
adambakerwa 4:cf765fff4e0e 60 move = runner.jump(move, lcd);
adambakerwa 4:cf765fff4e0e 61
adambakerwa 5:37b37f48e8bf 62 move = runner.wallJumpL(move, lcd, speed);
adambakerwa 5:37b37f48e8bf 63
adambakerwa 5:37b37f48e8bf 64 move = runner.wallJumpR(move, lcd, speed);
adambakerwa 4:cf765fff4e0e 65
adambakerwa 3:c1f4968111d7 66 move = runner.runLeft(move, lcd, speed);
adambakerwa 3:c1f4968111d7 67
adambakerwa 3:c1f4968111d7 68 move = runner.runRight(move, lcd, speed);
adambakerwa 6:cef9c2853315 69
adambakerwa 6:cef9c2853315 70
adambakerwa 2:1ad390d81d81 71
adambakerwa 4:cf765fff4e0e 72 move = runner.fall(move, lcd);
adambakerwa 2:1ad390d81d81 73
adambakerwa 6:cef9c2853315 74
adambakerwa 6:cef9c2853315 75
adambakerwa 7:66ea4d394fea 76 /**char buffer[14];
adambakerwa 7:66ea4d394fea 77 sprintf(buffer,"%i",move.l);
adambakerwa 2:1ad390d81d81 78 lcd.printString(buffer,0,1);
adambakerwa 7:66ea4d394fea 79 */
adambakerwa 3:c1f4968111d7 80 char buffer1[14];
adambakerwa 7:66ea4d394fea 81 sprintf(buffer1,"%i",move.l);
adambakerwa 3:c1f4968111d7 82 lcd.printString(buffer1,0,0);
adambakerwa 2:1ad390d81d81 83
adambakerwa 5:37b37f48e8bf 84
adambakerwa 1:a3cce487dffe 85 lcd.refresh();
adambakerwa 1:a3cce487dffe 86
adambakerwa 1:a3cce487dffe 87 wait(1.0f/fps);
adambakerwa 1:a3cce487dffe 88
adambakerwa 1:a3cce487dffe 89 }
adambakerwa 1:a3cce487dffe 90 }
adambakerwa 1:a3cce487dffe 91
adambakerwa 1:a3cce487dffe 92
adambakerwa 2:1ad390d81d81 93