class for obstacles in Car_race game

Committer:
fy14aaz
Date:
Thu May 04 12:04:51 2017 +0000
Revision:
11:c0922d4fda7b
Parent:
10:515df7535b2f
final version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fy14aaz 0:f8968ec0ec1b 1 #ifndef OBSTACLES_H
fy14aaz 0:f8968ec0ec1b 2 #define OBSTACLES_H
fy14aaz 0:f8968ec0ec1b 3
fy14aaz 0:f8968ec0ec1b 4 #include "mbed.h"
fy14aaz 0:f8968ec0ec1b 5 #include "N5110.h"
fy14aaz 0:f8968ec0ec1b 6 #include "Gamepad.h"
fy14aaz 0:f8968ec0ec1b 7
fy14aaz 11:c0922d4fda7b 8 /** Car Obstacles
fy14aaz 11:c0922d4fda7b 9 * Obstacles.h
fy14aaz 11:c0922d4fda7b 10 * @brief this header file will contain all required functions used to draw the Obstacles
fy14aaz 11:c0922d4fda7b 11 * @brief updating them, checking for collisions as well as tracking the score
fy14aaz 11:c0922d4fda7b 12 *
fy14aaz 11:c0922d4fda7b 13 * @author Ahmed Abu Zaid
fy14aaz 11:c0922d4fda7b 14 *
fy14aaz 11:c0922d4fda7b 15 * @date 4/5/2017
fy14aaz 11:c0922d4fda7b 16 */
fy14aaz 0:f8968ec0ec1b 17 class Obstacles
fy14aaz 0:f8968ec0ec1b 18
fy14aaz 0:f8968ec0ec1b 19 {
fy14aaz 11:c0922d4fda7b 20
fy14aaz 11:c0922d4fda7b 21 public:
fy14aaz 11:c0922d4fda7b 22
fy14aaz 11:c0922d4fda7b 23 Obstacles();
fy14aaz 11:c0922d4fda7b 24 ~Obstacles();
fy14aaz 11:c0922d4fda7b 25
fy14aaz 11:c0922d4fda7b 26 /**
fy14aaz 11:c0922d4fda7b 27 * init Initialises the Obstacles.
fy14aaz 11:c0922d4fda7b 28 *
fy14aaz 11:c0922d4fda7b 29 * @param seed random number that specifies which position the obstacle shall be drawn at
fy14aaz 11:c0922d4fda7b 30 *
fy14aaz 11:c0922d4fda7b 31 * This function sets the initial values of scores and the seed for the obstacle
fy14aaz 11:c0922d4fda7b 32 */
fy14aaz 11:c0922d4fda7b 33 void init(int seed);
fy14aaz 11:c0922d4fda7b 34
fy14aaz 11:c0922d4fda7b 35 /**
fy14aaz 11:c0922d4fda7b 36 * draw draws the obstacles.
fy14aaz 11:c0922d4fda7b 37 *
fy14aaz 11:c0922d4fda7b 38 * @param lcd The object for the lcd screen class
fy14aaz 11:c0922d4fda7b 39 * @param seed random number that specifies which position the obstacle shall be drawn at
fy14aaz 11:c0922d4fda7b 40 *
fy14aaz 11:c0922d4fda7b 41 * This function prints the obstalces in one of three positions at the top of the screen
fy14aaz 11:c0922d4fda7b 42 * that are determined by the seed
fy14aaz 11:c0922d4fda7b 43 */
fy14aaz 11:c0922d4fda7b 44
fy14aaz 11:c0922d4fda7b 45 void draw(N5110 &lcd,int seed);
fy14aaz 11:c0922d4fda7b 46 /**
fy14aaz 11:c0922d4fda7b 47 * update it updates the values of the car's coordinates
fy14aaz 11:c0922d4fda7b 48 *
fy14aaz 11:c0922d4fda7b 49 * @param lcd The object for the lcd screen class
fy14aaz 11:c0922d4fda7b 50 *
fy14aaz 11:c0922d4fda7b 51 * This functions loops through the entire screen and stores the valuse of the pixels'
fy14aaz 11:c0922d4fda7b 52 * states, in order to shift the whole thing down
fy14aaz 11:c0922d4fda7b 53 */
fy14aaz 11:c0922d4fda7b 54 void update(N5110 &lcd);
fy14aaz 11:c0922d4fda7b 55
fy14aaz 11:c0922d4fda7b 56 /**
fy14aaz 11:c0922d4fda7b 57 * add_Score it increments the value of the score
fy14aaz 11:c0922d4fda7b 58 *
fy14aaz 11:c0922d4fda7b 59 * @param lcd The object for the lcd screen class
fy14aaz 11:c0922d4fda7b 60 *
fy14aaz 11:c0922d4fda7b 61 * This functions is called to increment the value of the score, which happens
fy14aaz 11:c0922d4fda7b 62 * when an obstacle leaves the screen from the bottom
fy14aaz 11:c0922d4fda7b 63 */
fy14aaz 11:c0922d4fda7b 64 void add_Score(N5110 &lcd);
fy14aaz 11:c0922d4fda7b 65
fy14aaz 11:c0922d4fda7b 66 /**
fy14aaz 11:c0922d4fda7b 67 * reduce_Score reduces the score
fy14aaz 11:c0922d4fda7b 68 *
fy14aaz 11:c0922d4fda7b 69 * This functions is called to reduce the value of the score each time a feature is used
fy14aaz 11:c0922d4fda7b 70 * such as R/L jumps, bullet fired etc
fy14aaz 11:c0922d4fda7b 71 */
fy14aaz 11:c0922d4fda7b 72 void reduce_Score();
fy14aaz 11:c0922d4fda7b 73
fy14aaz 11:c0922d4fda7b 74 /**
fy14aaz 11:c0922d4fda7b 75 * get_Score
fy14aaz 11:c0922d4fda7b 76 *
fy14aaz 11:c0922d4fda7b 77 * This functions returns the value of the adjustable score which is used in the
fy14aaz 11:c0922d4fda7b 78 * use of the features such as R/L jumps, bullet fired etc
fy14aaz 11:c0922d4fda7b 79 */
fy14aaz 11:c0922d4fda7b 80 int get_Score();
fy14aaz 11:c0922d4fda7b 81
fy14aaz 11:c0922d4fda7b 82 /**
fy14aaz 11:c0922d4fda7b 83 * get_TotalScore
fy14aaz 11:c0922d4fda7b 84 *
fy14aaz 11:c0922d4fda7b 85 * This functions returns the value of the total score that is printed on the screen
fy14aaz 11:c0922d4fda7b 86 * while the game running, as well as when the game is over
fy14aaz 11:c0922d4fda7b 87 */
fy14aaz 11:c0922d4fda7b 88 int get_TotalScore();
fy14aaz 11:c0922d4fda7b 89
fy14aaz 11:c0922d4fda7b 90 private:
fy14aaz 11:c0922d4fda7b 91
fy14aaz 11:c0922d4fda7b 92 int _Obstacle_pos_x; // x position of obstacle
fy14aaz 11:c0922d4fda7b 93 int _score; // adjustable score
fy14aaz 11:c0922d4fda7b 94 int _totalscore; // total/final score
fy14aaz 0:f8968ec0ec1b 95 };
fy14aaz 0:f8968ec0ec1b 96
fy14aaz 0:f8968ec0ec1b 97 #endif