Adam Baker 201166301

Dependencies:   mbed Gamepad N5110

Committer:
adambakerwa
Date:
Sat Mar 23 12:41:30 2019 +0000
Revision:
9:ddeafaadf984
Parent:
8:44678962ec01
Child:
10:a37a4d2c09e7
started to make the character

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 9:ddeafaadf984 16 int fps = 5;
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 6:cef9c2853315 50
adambakerwa 6:cef9c2853315 51
adambakerwa 2:1ad390d81d81 52
adambakerwa 9:ddeafaadf984 53 move = runner.fall(move);
adambakerwa 2:1ad390d81d81 54
adambakerwa 6:cef9c2853315 55
adambakerwa 6:cef9c2853315 56
adambakerwa 7:66ea4d394fea 57 /**char buffer[14];
adambakerwa 7:66ea4d394fea 58 sprintf(buffer,"%i",move.l);
adambakerwa 2:1ad390d81d81 59 lcd.printString(buffer,0,1);
adambakerwa 7:66ea4d394fea 60 */
adambakerwa 3:c1f4968111d7 61 char buffer1[14];
adambakerwa 9:ddeafaadf984 62 sprintf(buffer1,"%i",move.gp);
adambakerwa 3:c1f4968111d7 63 lcd.printString(buffer1,0,0);
adambakerwa 2:1ad390d81d81 64
adambakerwa 5:37b37f48e8bf 65
adambakerwa 1:a3cce487dffe 66 lcd.refresh();
adambakerwa 1:a3cce487dffe 67
adambakerwa 1:a3cce487dffe 68 wait(1.0f/fps);
adambakerwa 1:a3cce487dffe 69
adambakerwa 1:a3cce487dffe 70 }
adambakerwa 1:a3cce487dffe 71 }
adambakerwa 1:a3cce487dffe 72
adambakerwa 1:a3cce487dffe 73
adambakerwa 2:1ad390d81d81 74