class for bullet in Car_race game

Committer:
fy14aaz
Date:
Thu May 04 12:04:59 2017 +0000
Revision:
13:dd1ccafe3972
Parent:
11:61bbec4ede2c
final version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fy14aaz 1:6bd0cbdf15f7 1 #ifndef BULLET_H
fy14aaz 1:6bd0cbdf15f7 2 #define BULLET_H
fy14aaz 1:6bd0cbdf15f7 3
fy14aaz 1:6bd0cbdf15f7 4 #include "mbed.h"
fy14aaz 1:6bd0cbdf15f7 5 #include "N5110.h"
fy14aaz 1:6bd0cbdf15f7 6 #include "Gamepad.h"
fy14aaz 1:6bd0cbdf15f7 7
fy14aaz 13:dd1ccafe3972 8 /** Bullet Class
fy14aaz 13:dd1ccafe3972 9 * Bullet.h
fy14aaz 13:dd1ccafe3972 10 * @brief this header file will contain all required functions used to draw the bullet
fy14aaz 13:dd1ccafe3972 11 * @brief and control it by directing, deleting and restricting when to be used
fy14aaz 13:dd1ccafe3972 12 *
fy14aaz 13:dd1ccafe3972 13 * @author Ahmed Abu Zaid
fy14aaz 13:dd1ccafe3972 14 *
fy14aaz 13:dd1ccafe3972 15 * @date 4/5/2017
fy14aaz 13:dd1ccafe3972 16 */
fy14aaz 1:6bd0cbdf15f7 17 class Bullet
fy14aaz 1:6bd0cbdf15f7 18 {
fy14aaz 1:6bd0cbdf15f7 19
fy14aaz 1:6bd0cbdf15f7 20 public:
fy14aaz 1:6bd0cbdf15f7 21 Bullet();
fy14aaz 1:6bd0cbdf15f7 22 ~Bullet();
fy14aaz 13:dd1ccafe3972 23
fy14aaz 13:dd1ccafe3972 24 /**
fy14aaz 13:dd1ccafe3972 25 * init Initialises the bullet.
fy14aaz 13:dd1ccafe3972 26 *
fy14aaz 13:dd1ccafe3972 27 * @param CarHead Two dimentional array containing the car head coordinates
fy14aaz 13:dd1ccafe3972 28 *
fy14aaz 13:dd1ccafe3972 29 * This function sets the values of coordinates of the bullet
fy14aaz 13:dd1ccafe3972 30 * depending on the car head coordinates
fy14aaz 13:dd1ccafe3972 31 */
fy14aaz 11:61bbec4ede2c 32 void init(Vector2D CarHead);
fy14aaz 13:dd1ccafe3972 33
fy14aaz 13:dd1ccafe3972 34 /**
fy14aaz 13:dd1ccafe3972 35 * draw draws the bullet.
fy14aaz 13:dd1ccafe3972 36 *
fy14aaz 13:dd1ccafe3972 37 * @param lcd The object for the lcd screen class
fy14aaz 13:dd1ccafe3972 38 *
fy14aaz 13:dd1ccafe3972 39 * This function prints the bullet using the lcd object, and
fy14aaz 13:dd1ccafe3972 40 * depending on the updated values of the coordinates
fy14aaz 13:dd1ccafe3972 41 */
fy14aaz 1:6bd0cbdf15f7 42 void draw(N5110 &lcd);
fy14aaz 13:dd1ccafe3972 43
fy14aaz 13:dd1ccafe3972 44 /**
fy14aaz 13:dd1ccafe3972 45 * update it updates the values of the bullet's coordinates
fy14aaz 13:dd1ccafe3972 46 *
fy14aaz 13:dd1ccafe3972 47 * @param lcd The object for the lcd screen class
fy14aaz 13:dd1ccafe3972 48 * @param bulletDirection The direction of the bullet
fy14aaz 13:dd1ccafe3972 49 *
fy14aaz 13:dd1ccafe3972 50 * This functions updates the bullet's coordinates depending on the direction the bullet
fy14aaz 13:dd1ccafe3972 51 * going in which is supplied by the engine when a button is pressed
fy14aaz 13:dd1ccafe3972 52 */
fy14aaz 11:61bbec4ede2c 53 void update(N5110 &lcd,int bulletDirection);
fy14aaz 13:dd1ccafe3972 54
fy14aaz 13:dd1ccafe3972 55 /**
fy14aaz 13:dd1ccafe3972 56 * clear_Bullet clears the bullet
fy14aaz 13:dd1ccafe3972 57 *
fy14aaz 13:dd1ccafe3972 58 * @param lcd The object for the lcd screen class
fy14aaz 13:dd1ccafe3972 59 *
fy14aaz 13:dd1ccafe3972 60 * This function is used to clear the bullet before getting updated and re-drawn
fy14aaz 13:dd1ccafe3972 61 * in another place, or mybe re-initialised
fy14aaz 13:dd1ccafe3972 62 */
fy14aaz 13:dd1ccafe3972 63 void clear_Bullet(N5110 &lcd);
fy14aaz 13:dd1ccafe3972 64
fy14aaz 13:dd1ccafe3972 65 /**
fy14aaz 13:dd1ccafe3972 66 * destroy_Obstacles clears obstacle when colliding with a bullet
fy14aaz 13:dd1ccafe3972 67 *
fy14aaz 13:dd1ccafe3972 68 * @param lcd The object for the lcd screen class
fy14aaz 13:dd1ccafe3972 69 *
fy14aaz 13:dd1ccafe3972 70 * This function clears any obstacle that collides with a bullet, it loops through
fy14aaz 13:dd1ccafe3972 71 * the area of collision and clears the obstalce as well as the bullet
fy14aaz 13:dd1ccafe3972 72 */
fy14aaz 13:dd1ccafe3972 73 void destroy_Obstacles(N5110 &lcd);
fy14aaz 1:6bd0cbdf15f7 74
fy14aaz 1:6bd0cbdf15f7 75 private:
fy14aaz 13:dd1ccafe3972 76
fy14aaz 13:dd1ccafe3972 77 // variables
fy14aaz 13:dd1ccafe3972 78 int _bullet_x; // bullet x coordinate
fy14aaz 13:dd1ccafe3972 79 int _bullet_y; // bullet y coordinate
fy14aaz 13:dd1ccafe3972 80
fy14aaz 1:6bd0cbdf15f7 81 };
fy14aaz 1:6bd0cbdf15f7 82 #endif