Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp@4:cf765fff4e0e, 2019-03-21 (annotated)
- Committer:
- adambakerwa
- Date:
- Thu Mar 21 17:25:52 2019 +0000
- Revision:
- 4:cf765fff4e0e
- Parent:
- 3:c1f4968111d7
- Child:
- 5:37b37f48e8bf
Wall Jump Success
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 | 1:a3cce487dffe | 5 | |
adambakerwa | 1:a3cce487dffe | 6 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
adambakerwa | 1:a3cce487dffe | 7 | Gamepad pad; |
adambakerwa | 1:a3cce487dffe | 8 | Runner runner; |
adambakerwa | 1:a3cce487dffe | 9 | |
adambakerwa | 1:a3cce487dffe | 10 | int main() { |
adambakerwa | 1:a3cce487dffe | 11 | |
adambakerwa | 2:1ad390d81d81 | 12 | int fps = 12; |
adambakerwa | 1:a3cce487dffe | 13 | |
adambakerwa | 1:a3cce487dffe | 14 | pad.init(); |
adambakerwa | 1:a3cce487dffe | 15 | lcd.init(); |
adambakerwa | 1:a3cce487dffe | 16 | |
adambakerwa | 1:a3cce487dffe | 17 | Move move; |
adambakerwa | 1:a3cce487dffe | 18 | |
adambakerwa | 1:a3cce487dffe | 19 | move = runner.init(move); |
adambakerwa | 1:a3cce487dffe | 20 | |
adambakerwa | 1:a3cce487dffe | 21 | while(1) { |
adambakerwa | 1:a3cce487dffe | 22 | |
adambakerwa | 1:a3cce487dffe | 23 | lcd.clear(); |
adambakerwa | 1:a3cce487dffe | 24 | |
adambakerwa | 1:a3cce487dffe | 25 | lcd.drawLine(0,40,84,40,1); |
adambakerwa | 4:cf765fff4e0e | 26 | lcd.drawLine(20,20,20,30,1); |
adambakerwa | 4:cf765fff4e0e | 27 | lcd.drawLine(40,30,40,10,1); |
adambakerwa | 4:cf765fff4e0e | 28 | //lcd.drawLine(40,30,40,40,1); |
adambakerwa | 4:cf765fff4e0e | 29 | |
adambakerwa | 2:1ad390d81d81 | 30 | |
adambakerwa | 1:a3cce487dffe | 31 | lcd.drawCircle(move.x,move.y,3,FILL_BLACK); |
adambakerwa | 1:a3cce487dffe | 32 | |
adambakerwa | 4:cf765fff4e0e | 33 | float speed = runner.getSpeed(pad); |
adambakerwa | 1:a3cce487dffe | 34 | |
adambakerwa | 4:cf765fff4e0e | 35 | move = runner.buttonPress(move, lcd, pad); |
adambakerwa | 4:cf765fff4e0e | 36 | |
adambakerwa | 4:cf765fff4e0e | 37 | move = runner.jump(move, lcd); |
adambakerwa | 4:cf765fff4e0e | 38 | |
adambakerwa | 4:cf765fff4e0e | 39 | move = runner.wallJumpR(move, lcd, speed); |
adambakerwa | 4:cf765fff4e0e | 40 | |
adambakerwa | 3:c1f4968111d7 | 41 | move = runner.runLeft(move, lcd, speed); |
adambakerwa | 3:c1f4968111d7 | 42 | |
adambakerwa | 3:c1f4968111d7 | 43 | move = runner.runRight(move, lcd, speed); |
adambakerwa | 2:1ad390d81d81 | 44 | |
adambakerwa | 4:cf765fff4e0e | 45 | move = runner.fall(move, lcd); |
adambakerwa | 2:1ad390d81d81 | 46 | |
adambakerwa | 2:1ad390d81d81 | 47 | char buffer[14]; |
adambakerwa | 4:cf765fff4e0e | 48 | sprintf(buffer,"x = %i",move.j); |
adambakerwa | 2:1ad390d81d81 | 49 | lcd.printString(buffer,0,1); |
adambakerwa | 3:c1f4968111d7 | 50 | char buffer1[14]; |
adambakerwa | 4:cf765fff4e0e | 51 | sprintf(buffer1,"w = %i",move.wjr); |
adambakerwa | 3:c1f4968111d7 | 52 | lcd.printString(buffer1,0,0); |
adambakerwa | 2:1ad390d81d81 | 53 | |
adambakerwa | 1:a3cce487dffe | 54 | lcd.refresh(); |
adambakerwa | 1:a3cce487dffe | 55 | |
adambakerwa | 1:a3cce487dffe | 56 | wait(1.0f/fps); |
adambakerwa | 1:a3cce487dffe | 57 | |
adambakerwa | 1:a3cce487dffe | 58 | } |
adambakerwa | 1:a3cce487dffe | 59 | } |
adambakerwa | 1:a3cce487dffe | 60 | |
adambakerwa | 1:a3cce487dffe | 61 | |
adambakerwa | 2:1ad390d81d81 | 62 |