Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Obstacles/Obstacles.cpp
- Committer:
- el15ss
- Date:
- 2017-05-04
- Revision:
- 7:887651afda26
- Parent:
- 6:bf601a65cb27
File content as of revision 7:887651afda26:
#include "Obstacles.h" void Obstacles::init() { //fprintf("in obstacle 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 //fprintf("Obstacle being drawn"); lcd.setPixel(obsPosX,obsPosY); } //To move the obstacle void Obstacles::updateObstacle() { //Updating the position of the obstacle on the screen and setting its speed //fprintf("updating th obstaclee to make it move"); obsPosY =obsPosY+1; } //Function to check if the obstacle has reached the end of the screen void Obstacles::obstacleStatus(Vector2D p) { //fprintf("in obstacle status"); //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() { //fprintf("in obstacle get pos"); Vector2D p = {obsPosX,obsPosY}; //fprintf("the value of p is %d", p); return p; } //Returns the status of the obstacle bool Obstacles::getObstacleStatus() { //fprintf("in get obstacle status"); //fprintf("The value of obstacle status is (in 0/1) %d",obStatus); //Used to check when to initialise and render the obstacle return obStatus; }