SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Obstacle.h
- Committer:
- jboettcher
- Date:
- 2016-10-28
- Revision:
- 5:f51cdddf541e
- Parent:
- 4:dbd0e3604beb
- Parent:
- 3:7a7157ff710f
- Child:
- 6:7f8c3169483a
- Child:
- 8:56a24df93680
File content as of revision 5:f51cdddf541e:
class Obstacle { int x1,x2,y1,y2; uLCD_4DGL uLCD; bool direction; public: Obstacle(int x1, int x2, int y1, int y2, uLCD_4DGL uLCD); void drawObstacle(); void move(int speed); void updateLocation(); void setULCD(uLCD_4DGL uLCD); void changeDirection();// need change direction when hitting wall void setDirection(bool direction); }; Obstacle::Obstacle(int a, int b, int c, int d, uLCD_4DGL e) { x1 = a; x2 = b; y1 = c; y2 = d; this->uLCD = e; } void Obstacle::setULCD( void Obstacle::drawObstacle() { uLCD.filled_rectangle(x1,y1,x2,y2,0xFFFFFF); } void Obstacle::move(int speed) { if (direction==1) { x1 += speed; x2 += speed; } else { x1 -= speed; x2 -= speed; } } void Obstacle::changeDirection() { direction = !direction } void Obstacle::setDirection(bool a) { direction = a; }