Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Obstacles/Obstacles.cpp
- Committer:
- el15ss
- Date:
- 2017-05-03
- Revision:
- 3:0c690f1c04d8
- Parent:
- 2:98a41609c827
- Child:
- 4:2fdafb53eac2
File content as of revision 3:0c690f1c04d8:
#include "Obstacles.h" void Obstacles::init() { //Initializing the X and Y co ordinates of the obstacle obsPosX = rand() % 84; obsPosY = rand() % 42-42; //variable to store the status of the obstacle obStatus = true; } void Obstacles::draw(N5110 &lcd) { //Drawing the character lcd.setPixel(obsPosX,obsPosY); } //To move the obstacle void Obstacles::updateObstacle() { //Updating the position of the obstacle on the screen and setting its speed obsPosY =obsPosY+1; } //Function to check if the obstacle has reached the end of the screen void Obstacles::obstacleStatus(Vector2D p) { //Update status if at end of the screen if(obsPosY > HEIGHT) { obStatus = false; } } //Returns the postion (x,y) of the obstacle on the screen Vector2D Obstacles::getObstaclePos() { Vector2D p = {obsPosX,obsPosY}; return p; } //Returns the status of the obstacle bool Obstacles::getObstacleStatus() { //Used to check when to initialise and render the obstacle return obStatus; }