Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Diff: Obstacles/Obstacles.cpp
- Revision:
- 0:12cfe63faa6a
- Child:
- 1:db9ff66f67c8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Obstacles/Obstacles.cpp Fri Apr 28 09:00:21 2017 +0000 @@ -0,0 +1,69 @@ + + +#include "Obstacles.h" + +Obstacles::Obstacles() +{ + +} + +Obstacles::~Obstacles() +{ + +} + +void Obstacles::init() +{ + _x = rand() % 84; + _y = rand() % 42-42; + _status = 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.drawCircle(_x,_y,2,FILL_BLACK); + lcd.setPixel(_x,_y); + + + + +} + +void Obstacles::Obstacles_Status(Vector2D p) +{ + /* if(((p.x<_x+3)&&(p.x>_x-3))&&((p.y<_y+3)&&(p.y>_y-3))){ + + _status = false; + } + */ + if(_y > HEIGHT) + { + _status = false; + } +} + +void Obstacles::update() +{ + _y =_y+1; + /* if(!_status) + { + _y = HEIGHT + 3; + }*/ +} + + + +Vector2D Obstacles::get_pos() { + Vector2D p = {_x,_y}; + return p; +} +bool Obstacles::get_status(){ + return _status; + + } + + \ No newline at end of file