runner
Dependencies: mbed
Obstacle/Obstacle.cpp
- Committer:
- kamtas
- Date:
- 2019-05-09
- Revision:
- 8:5fde4e54a2f4
- Parent:
- 4:7fca66882a00
File content as of revision 8:5fde4e54a2f4:
#include "Obstacle.h" // nothing doing in the constructor and destructor Obstacle::Obstacle() { } Obstacle::~Obstacle() { } void Obstacle::init(int y,int height,int width) { _x = WIDTH; _y = y; _height = height; _width = width; _speed = 0; } void Obstacle::draw(N5110 &lcd) { lcd.drawRect(_x,_y,_width,_height,FILL_BLACK); } void Obstacle::update(bool ran) { if ( (ran == 1) && (_speed == 0) ) { _speed = 3; _x = WIDTH; } else if ( (_x < -1) ) { _x = WIDTH; _speed = 0; } _x -= _speed; } Vector2D Obstacle::get_pos() { Vector2D p = {_x,_y}; return p; }