complete
Dependencies: 4DGL-uLCD-SE PinDetect mbed
Fork of my2036lab2robotLCD by
Robot.h@1:5a1311f0ea06, 2016-11-06 (annotated)
- Committer:
- jboettcher
- Date:
- Sun Nov 06 22:25:24 2016 +0000
- Revision:
- 1:5a1311f0ea06
- Parent:
- 0:343fbeea672c
complete;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jboettcher | 1:5a1311f0ea06 | 1 | #include <iostream> |
jboettcher | 1:5a1311f0ea06 | 2 | using namespace std; |
jboettcher | 1:5a1311f0ea06 | 3 | |
4180_1 | 0:343fbeea672c | 4 | class Robot |
4180_1 | 0:343fbeea672c | 5 | { |
4180_1 | 0:343fbeea672c | 6 | public: |
4180_1 | 0:343fbeea672c | 7 | void draw() { |
jboettcher | 1:5a1311f0ea06 | 8 | uLCD.filled_circle(xPosition, yPosition, 2, BLUE); |
jboettcher | 1:5a1311f0ea06 | 9 | uLCD.filled_circle(xPosition - 8, yPosition - 8, 4, GREEN); |
jboettcher | 1:5a1311f0ea06 | 10 | uLCD.filled_circle(xPosition + 8, yPosition - 8, 4, GREEN); |
jboettcher | 1:5a1311f0ea06 | 11 | uLCD.filled_rectangle(xPosition - 5, yPosition + 10, xPosition + 5, yPosition + 5 , BLACK); |
jboettcher | 1:5a1311f0ea06 | 12 | uLCD.circle(xPosition, yPosition, 18, BLACK); } |
4180_1 | 0:343fbeea672c | 13 | void erase() { |
jboettcher | 1:5a1311f0ea06 | 14 | uLCD.filled_rectangle(0, 126, 126, 26, RED); } |
4180_1 | 0:343fbeea672c | 15 | void moveForward(int distance) { |
jboettcher | 1:5a1311f0ea06 | 16 | yPosition++; } |
4180_1 | 0:343fbeea672c | 17 | void moveBackward(int distance) { |
jboettcher | 1:5a1311f0ea06 | 18 | yPosition--; } |
4180_1 | 0:343fbeea672c | 19 | void moveLeft(int distance) { |
jboettcher | 1:5a1311f0ea06 | 20 | xPosition--; } |
4180_1 | 0:343fbeea672c | 21 | void moveRight(int distance) { |
jboettcher | 1:5a1311f0ea06 | 22 | xPosition++; } |
4180_1 | 0:343fbeea672c | 23 | Robot() { |
jboettcher | 1:5a1311f0ea06 | 24 | xPosition = 63; |
jboettcher | 1:5a1311f0ea06 | 25 | yPosition = 63; |
4180_1 | 0:343fbeea672c | 26 | } |
4180_1 | 0:343fbeea672c | 27 | private: |
4180_1 | 0:343fbeea672c | 28 | int xPosition; |
4180_1 | 0:343fbeea672c | 29 | int yPosition; |
jboettcher | 1:5a1311f0ea06 | 30 | }; |