SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Obstacle.h@5:f51cdddf541e, 2016-10-28 (annotated)
- Committer:
- jboettcher
- Date:
- Fri Oct 28 00:36:11 2016 +0000
- Revision:
- 5:f51cdddf541e
- Parent:
- 4:dbd0e3604beb
- Parent:
- 3:7a7157ff710f
- Child:
- 6:7f8c3169483a
- Child:
- 8:56a24df93680
starting shooter class;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jboettcher | 1:8a3fa9e90572 | 1 | class Obstacle |
jboettcher | 1:8a3fa9e90572 | 2 | { |
jboettcher | 5:f51cdddf541e | 3 | int x1,x2,y1,y2; |
jboettcher | 5:f51cdddf541e | 4 | uLCD_4DGL uLCD; |
jboettcher | 5:f51cdddf541e | 5 | bool direction; |
jboettcher | 5:f51cdddf541e | 6 | |
jboettcher | 5:f51cdddf541e | 7 | public: |
jboettcher | 5:f51cdddf541e | 8 | Obstacle(int x1, int x2, int y1, int y2, uLCD_4DGL uLCD); |
jboettcher | 5:f51cdddf541e | 9 | void drawObstacle(); |
jboettcher | 5:f51cdddf541e | 10 | void move(int speed); |
jboettcher | 5:f51cdddf541e | 11 | void updateLocation(); |
jboettcher | 5:f51cdddf541e | 12 | void setULCD(uLCD_4DGL uLCD); |
jboettcher | 5:f51cdddf541e | 13 | void changeDirection();// need change direction when hitting wall |
jboettcher | 5:f51cdddf541e | 14 | void setDirection(bool direction); |
jboettcher | 5:f51cdddf541e | 15 | }; |
jboettcher | 5:f51cdddf541e | 16 | |
jboettcher | 5:f51cdddf541e | 17 | Obstacle::Obstacle(int a, int b, int c, int d, uLCD_4DGL e) { |
jboettcher | 5:f51cdddf541e | 18 | x1 = a; |
jboettcher | 5:f51cdddf541e | 19 | x2 = b; |
jboettcher | 5:f51cdddf541e | 20 | y1 = c; |
jboettcher | 5:f51cdddf541e | 21 | y2 = d; |
jboettcher | 5:f51cdddf541e | 22 | this->uLCD = e; |
jboettcher | 5:f51cdddf541e | 23 | } |
jboettcher | 5:f51cdddf541e | 24 | |
jboettcher | 5:f51cdddf541e | 25 | void Obstacle::setULCD( |
jboettcher | 5:f51cdddf541e | 26 | |
jboettcher | 5:f51cdddf541e | 27 | void Obstacle::drawObstacle() { |
jboettcher | 5:f51cdddf541e | 28 | uLCD.filled_rectangle(x1,y1,x2,y2,0xFFFFFF); |
jboettcher | 5:f51cdddf541e | 29 | } |
jboettcher | 5:f51cdddf541e | 30 | |
jboettcher | 5:f51cdddf541e | 31 | void Obstacle::move(int speed) { |
jboettcher | 5:f51cdddf541e | 32 | if (direction==1) { |
jboettcher | 5:f51cdddf541e | 33 | x1 += speed; |
jboettcher | 5:f51cdddf541e | 34 | x2 += speed; |
jboettcher | 5:f51cdddf541e | 35 | } |
jboettcher | 5:f51cdddf541e | 36 | else { |
jboettcher | 5:f51cdddf541e | 37 | x1 -= speed; |
jboettcher | 5:f51cdddf541e | 38 | x2 -= speed; |
jboettcher | 5:f51cdddf541e | 39 | } |
jboettcher | 5:f51cdddf541e | 40 | } |
jboettcher | 5:f51cdddf541e | 41 | |
jboettcher | 5:f51cdddf541e | 42 | void Obstacle::changeDirection() { |
jboettcher | 5:f51cdddf541e | 43 | direction = !direction |
jboettcher | 5:f51cdddf541e | 44 | } |
jboettcher | 5:f51cdddf541e | 45 | |
jboettcher | 5:f51cdddf541e | 46 | void Obstacle::setDirection(bool a) { |
jboettcher | 5:f51cdddf541e | 47 | direction = a; |
jboettcher | 5:f51cdddf541e | 48 | } |