![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Diff: Obstacles/Obstacles.cpp
- Revision:
- 1:db9ff66f67c8
- Parent:
- 0:12cfe63faa6a
- Child:
- 2:98a41609c827
diff -r 12cfe63faa6a -r db9ff66f67c8 Obstacles/Obstacles.cpp --- a/Obstacles/Obstacles.cpp Fri Apr 28 09:00:21 2017 +0000 +++ b/Obstacles/Obstacles.cpp Fri Apr 28 16:30:47 2017 +0000 @@ -2,67 +2,60 @@ #include "Obstacles.h" -Obstacles::Obstacles() -{ - -} - -Obstacles::~Obstacles() -{ - -} void Obstacles::init() { - _x = rand() % 84; - _y = rand() % 42-42; - _status = true; + obsPosX = rand() % 84; + obsPosY = rand() % 42-42; + obStatus = true; } void Obstacles::draw(N5110 &lcd) { // draw Obstacless in screen buffer. - //lcd.drawRect(_x-4,_y-3,3,3,FILL_BLACK); - //lcd.drawLine(_x-3, _y-3,_x-3,_y+1,1); + //lcd.drawRect(obsPosX-4,obsPosY-3,3,3,FILL_BLACK); + //lcd.drawLine(obsPosX-3, obsPosY-3,obsPosX-3,obsPosY+1,1); - //lcd.drawCircle(_x,_y,2,FILL_BLACK); - lcd.setPixel(_x,_y); - + //lcd.drawCircle(obsPosX,obsPosY,2,FILL_BLACK); + lcd.setPixel(obsPosX,obsPosY); + + } -void Obstacles::Obstacles_Status(Vector2D p) +void Obstacles::obstacleStatus(Vector2D p) { - /* if(((p.x<_x+3)&&(p.x>_x-3))&&((p.y<_y+3)&&(p.y>_y-3))){ + /* if(((p.x<obsPosX+3)&&(p.x>obsPosX-3))&&((p.y<obsPosY+3)&&(p.y>obsPosY-3))){ - _status = false; + obstacleStatus = false; } */ - if(_y > HEIGHT) + if(obsPosY > HEIGHT) { - _status = false; + obStatus = false; } } -void Obstacles::update() +void Obstacles::updateObstacle() { - _y =_y+1; - /* if(!_status) - { - _y = HEIGHT + 3; - }*/ + obsPosY =obsPosY+1; + } -Vector2D Obstacles::get_pos() { - Vector2D p = {_x,_y}; +Vector2D Obstacles::getObstaclePos() +{ + Vector2D p = {obsPosX,obsPosY}; return p; } -bool Obstacles::get_status(){ - return _status; + + +bool Obstacles::getObstacleStatus() +{ + return obStatus; }