Adam Baker 201166301
Dependencies: mbed Gamepad N5110
main.cpp@5:37b37f48e8bf, 2019-03-21 (annotated)
- Committer:
- adambakerwa
- Date:
- Thu Mar 21 17:55:37 2019 +0000
- Revision:
- 5:37b37f48e8bf
- Parent:
- 4:cf765fff4e0e
- Child:
- 6:cef9c2853315
wall jump left worked on
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 | 5:37b37f48e8bf | 39 | move = runner.wallJumpL(move, lcd, speed); |
adambakerwa | 5:37b37f48e8bf | 40 | |
adambakerwa | 5:37b37f48e8bf | 41 | move = runner.wallJumpR(move, lcd, speed); |
adambakerwa | 4:cf765fff4e0e | 42 | |
adambakerwa | 3:c1f4968111d7 | 43 | move = runner.runLeft(move, lcd, speed); |
adambakerwa | 3:c1f4968111d7 | 44 | |
adambakerwa | 3:c1f4968111d7 | 45 | move = runner.runRight(move, lcd, speed); |
adambakerwa | 2:1ad390d81d81 | 46 | |
adambakerwa | 4:cf765fff4e0e | 47 | move = runner.fall(move, lcd); |
adambakerwa | 2:1ad390d81d81 | 48 | |
adambakerwa | 5:37b37f48e8bf | 49 | /**char buffer[14]; |
adambakerwa | 4:cf765fff4e0e | 50 | sprintf(buffer,"x = %i",move.j); |
adambakerwa | 2:1ad390d81d81 | 51 | lcd.printString(buffer,0,1); |
adambakerwa | 5:37b37f48e8bf | 52 | */ |
adambakerwa | 3:c1f4968111d7 | 53 | char buffer1[14]; |
adambakerwa | 5:37b37f48e8bf | 54 | sprintf(buffer1,"w = %i",move.wjl); |
adambakerwa | 3:c1f4968111d7 | 55 | lcd.printString(buffer1,0,0); |
adambakerwa | 2:1ad390d81d81 | 56 | |
adambakerwa | 5:37b37f48e8bf | 57 | |
adambakerwa | 1:a3cce487dffe | 58 | lcd.refresh(); |
adambakerwa | 1:a3cce487dffe | 59 | |
adambakerwa | 1:a3cce487dffe | 60 | wait(1.0f/fps); |
adambakerwa | 1:a3cce487dffe | 61 | |
adambakerwa | 1:a3cce487dffe | 62 | } |
adambakerwa | 1:a3cce487dffe | 63 | } |
adambakerwa | 1:a3cce487dffe | 64 | |
adambakerwa | 1:a3cce487dffe | 65 | |
adambakerwa | 2:1ad390d81d81 | 66 |