![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp@11:dcb38924d96b, 2019-03-24 (annotated)
- Committer:
- adambakerwa
- Date:
- Sun Mar 24 20:03:50 2019 +0000
- Revision:
- 11:dcb38924d96b
- Parent:
- 10:a37a4d2c09e7
- Child:
- 12:1253afc5d536
animation bits
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:cf765fff4e0e | 29 | float speed = runner.getSpeed(pad); |
adambakerwa | 1:a3cce487dffe | 30 | |
adambakerwa | 11:dcb38924d96b | 31 | //lcd.drawCircle(move.x,move.y,3,FILL_BLACK); |
adambakerwa | 11:dcb38924d96b | 32 | runner.runnerState(move, lcd, speed); |
adambakerwa | 11:dcb38924d96b | 33 | |
adambakerwa | 11:dcb38924d96b | 34 | move = runner.nextLevel(move); //must happen befofre 'fall' otherwise runner can fall out of screen |
adambakerwa | 11:dcb38924d96b | 35 | |
adambakerwa | 11:dcb38924d96b | 36 | runner.whatLevel(move, lcd); |
adambakerwa | 11:dcb38924d96b | 37 | |
adambakerwa | 4:cf765fff4e0e | 38 | move = runner.buttonPress(move, lcd, pad); |
adambakerwa | 4:cf765fff4e0e | 39 | |
adambakerwa | 4:cf765fff4e0e | 40 | move = runner.jump(move, lcd); |
adambakerwa | 4:cf765fff4e0e | 41 | |
adambakerwa | 5:37b37f48e8bf | 42 | move = runner.wallJumpL(move, lcd, speed); |
adambakerwa | 5:37b37f48e8bf | 43 | |
adambakerwa | 5:37b37f48e8bf | 44 | move = runner.wallJumpR(move, lcd, speed); |
adambakerwa | 4:cf765fff4e0e | 45 | |
adambakerwa | 3:c1f4968111d7 | 46 | move = runner.runLeft(move, lcd, speed); |
adambakerwa | 3:c1f4968111d7 | 47 | |
adambakerwa | 3:c1f4968111d7 | 48 | move = runner.runRight(move, lcd, speed); |
adambakerwa | 2:1ad390d81d81 | 49 | |
adambakerwa | 10:a37a4d2c09e7 | 50 | move = runner.fall(move, lcd); |
adambakerwa | 2:1ad390d81d81 | 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 | 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 | 11:dcb38924d96b | 59 | |
adambakerwa | 3:c1f4968111d7 | 60 | char buffer1[14]; |
adambakerwa | 11:dcb38924d96b | 61 | sprintf(buffer1,"%i",move.f); |
adambakerwa | 3:c1f4968111d7 | 62 | lcd.printString(buffer1,0,0); |
adambakerwa | 2:1ad390d81d81 | 63 | |
adambakerwa | 5:37b37f48e8bf | 64 | |
adambakerwa | 1:a3cce487dffe | 65 | lcd.refresh(); |
adambakerwa | 1:a3cce487dffe | 66 | |
adambakerwa | 1:a3cce487dffe | 67 | wait(1.0f/fps); |
adambakerwa | 1:a3cce487dffe | 68 | |
adambakerwa | 1:a3cce487dffe | 69 | } |
adambakerwa | 1:a3cce487dffe | 70 | } |
adambakerwa | 1:a3cce487dffe | 71 | |
adambakerwa | 1:a3cce487dffe | 72 | |
adambakerwa | 2:1ad390d81d81 | 73 |