Stick_Runner

Dependencies:   FXOS8700CQ Gamepad N5110 SDFileSystem mbed

Fork of Stick_Runner by Samrudh Sharma

Committer:
el15ss
Date:
Wed May 03 18:00:37 2017 +0000
Revision:
4:2fdafb53eac2
Parent:
3:0c690f1c04d8
Child:
6:bf601a65cb27
Completed inline and DOygen commenting

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15ss 0:12cfe63faa6a 1
el15ss 0:12cfe63faa6a 2
el15ss 0:12cfe63faa6a 3 #include "Obstacles.h"
el15ss 0:12cfe63faa6a 4
el15ss 0:12cfe63faa6a 5
el15ss 0:12cfe63faa6a 6 void Obstacles::init()
el15ss 0:12cfe63faa6a 7 {
el15ss 3:0c690f1c04d8 8 //Initializing the X and Y co ordinates of the obstacle
el15ss 1:db9ff66f67c8 9 obsPosX = rand() % 84;
el15ss 1:db9ff66f67c8 10 obsPosY = rand() % 42-42;
el15ss 3:0c690f1c04d8 11
el15ss 3:0c690f1c04d8 12 //variable to store the status of the obstacle
el15ss 1:db9ff66f67c8 13 obStatus = true;
el15ss 0:12cfe63faa6a 14 }
el15ss 0:12cfe63faa6a 15
el15ss 0:12cfe63faa6a 16 void Obstacles::draw(N5110 &lcd)
el15ss 0:12cfe63faa6a 17 {
el15ss 3:0c690f1c04d8 18 //Drawing the character
el15ss 1:db9ff66f67c8 19 lcd.setPixel(obsPosX,obsPosY);
el15ss 1:db9ff66f67c8 20
el15ss 1:db9ff66f67c8 21
el15ss 0:12cfe63faa6a 22
el15ss 0:12cfe63faa6a 23
el15ss 0:12cfe63faa6a 24
el15ss 0:12cfe63faa6a 25 }
el15ss 0:12cfe63faa6a 26
el15ss 3:0c690f1c04d8 27 //To move the obstacle
el15ss 2:98a41609c827 28 void Obstacles::updateObstacle()
el15ss 2:98a41609c827 29 {
el15ss 3:0c690f1c04d8 30 //Updating the position of the obstacle on the screen and setting its speed
el15ss 2:98a41609c827 31 obsPosY =obsPosY+1;
el15ss 2:98a41609c827 32
el15ss 2:98a41609c827 33 }
el15ss 2:98a41609c827 34
el15ss 3:0c690f1c04d8 35 //Function to check if the obstacle has reached the end of the screen
el15ss 1:db9ff66f67c8 36 void Obstacles::obstacleStatus(Vector2D p)
el15ss 0:12cfe63faa6a 37 {
el15ss 3:0c690f1c04d8 38 //Update status if at end of the screen
el15ss 1:db9ff66f67c8 39 if(obsPosY > HEIGHT)
el15ss 0:12cfe63faa6a 40 {
el15ss 1:db9ff66f67c8 41 obStatus = false;
el15ss 0:12cfe63faa6a 42 }
el15ss 0:12cfe63faa6a 43 }
el15ss 0:12cfe63faa6a 44
el15ss 3:0c690f1c04d8 45 //Returns the postion (x,y) of the obstacle on the screen
el15ss 1:db9ff66f67c8 46 Vector2D Obstacles::getObstaclePos()
el15ss 1:db9ff66f67c8 47 {
el15ss 1:db9ff66f67c8 48 Vector2D p = {obsPosX,obsPosY};
el15ss 0:12cfe63faa6a 49 return p;
el15ss 0:12cfe63faa6a 50 }
el15ss 1:db9ff66f67c8 51
el15ss 3:0c690f1c04d8 52 //Returns the status of the obstacle
el15ss 1:db9ff66f67c8 53 bool Obstacles::getObstacleStatus()
el15ss 1:db9ff66f67c8 54 {
el15ss 3:0c690f1c04d8 55 //Used to check when to initialise and render the obstacle
el15ss 1:db9ff66f67c8 56 return obStatus;
el15ss 0:12cfe63faa6a 57
el15ss 4:2fdafb53eac2 58 }
el15ss 0:12cfe63faa6a 59
el15ss 0:12cfe63faa6a 60