Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Fork of Stick_Runner by
Obstacles/Obstacles.h@4:2fdafb53eac2, 2017-05-03 (annotated)
- Committer:
- el15ss
- Date:
- Wed May 03 18:00:37 2017 +0000
- Revision:
- 4:2fdafb53eac2
- Parent:
- 3:0c690f1c04d8
Completed inline and DOygen commenting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15ss | 0:12cfe63faa6a | 1 | #ifndef Obstacles_H |
el15ss | 0:12cfe63faa6a | 2 | #define Obstacles_H |
el15ss | 0:12cfe63faa6a | 3 | |
el15ss | 0:12cfe63faa6a | 4 | #include "mbed.h" |
el15ss | 0:12cfe63faa6a | 5 | #include "N5110.h" |
el15ss | 0:12cfe63faa6a | 6 | #include "Gamepad.h" |
el15ss | 4:2fdafb53eac2 | 7 | /** Class Obstacles |
el15ss | 3:0c690f1c04d8 | 8 | @brief Class responsible for all the functionality of the obstacles including intialization, drawing, moving and updating it |
el15ss | 3:0c690f1c04d8 | 9 | @author Samrudh Sharma |
el15ss | 3:0c690f1c04d8 | 10 | @date |
el15ss | 4:2fdafb53eac2 | 11 | @classes |
el15ss | 3:0c690f1c04d8 | 12 | */ |
el15ss | 3:0c690f1c04d8 | 13 | |
el15ss | 3:0c690f1c04d8 | 14 | |
el15ss | 0:12cfe63faa6a | 15 | |
el15ss | 0:12cfe63faa6a | 16 | class Obstacles |
el15ss | 0:12cfe63faa6a | 17 | { |
el15ss | 0:12cfe63faa6a | 18 | public: |
el15ss | 0:12cfe63faa6a | 19 | |
el15ss | 3:0c690f1c04d8 | 20 | /** Initialise display |
el15ss | 3:0c690f1c04d8 | 21 | * |
el15ss | 3:0c690f1c04d8 | 22 | * Powers up the display and turns on backlight (50% brightness default). |
el15ss | 3:0c690f1c04d8 | 23 | * Intialises the charchter status, x and y co-ordinate of the obstacle. |
el15ss | 3:0c690f1c04d8 | 24 | */ |
el15ss | 0:12cfe63faa6a | 25 | void init(); |
el15ss | 3:0c690f1c04d8 | 26 | |
el15ss | 3:0c690f1c04d8 | 27 | /** Function to draw the obstacle |
el15ss | 3:0c690f1c04d8 | 28 | * |
el15ss | 3:0c690f1c04d8 | 29 | * Draws the obstacle to the display using the N5110 library and its object lcd. |
el15ss | 3:0c690f1c04d8 | 30 | * |
el15ss | 3:0c690f1c04d8 | 31 | */ |
el15ss | 0:12cfe63faa6a | 32 | void draw(N5110 &lcd); |
el15ss | 3:0c690f1c04d8 | 33 | |
el15ss | 3:0c690f1c04d8 | 34 | /** Updates/Moves Obstacle |
el15ss | 3:0c690f1c04d8 | 35 | * |
el15ss | 3:0c690f1c04d8 | 36 | * Helps the Obstacle move by updating its position on the screen by 1 pixel each time |
el15ss | 3:0c690f1c04d8 | 37 | * therefore setting its speed aswell. |
el15ss | 3:0c690f1c04d8 | 38 | */ |
el15ss | 1:db9ff66f67c8 | 39 | void updateObstacle(); |
el15ss | 3:0c690f1c04d8 | 40 | |
el15ss | 3:0c690f1c04d8 | 41 | /** Obstacle Status |
el15ss | 3:0c690f1c04d8 | 42 | * |
el15ss | 3:0c690f1c04d8 | 43 | * This fuction helps to check whether the obstacle has reached the bottom of the screen and updates the obstacle status |
el15ss | 3:0c690f1c04d8 | 44 | * to false so that the obstacles can be generated again this creating a continuous flow of obstacles |
el15ss | 3:0c690f1c04d8 | 45 | * |
el15ss | 3:0c690f1c04d8 | 46 | * @param p - stores the 2D location i.e. the (x,y) co-ordinate of the cetre point of the obstacle on the screen . |
el15ss | 3:0c690f1c04d8 | 47 | */ |
el15ss | 1:db9ff66f67c8 | 48 | void obstacleStatus(Vector2D p); |
el15ss | 3:0c690f1c04d8 | 49 | |
el15ss | 3:0c690f1c04d8 | 50 | /** Obstacle Position |
el15ss | 3:0c690f1c04d8 | 51 | * |
el15ss | 3:0c690f1c04d8 | 52 | * Returns the 2D location i.e. the (x,y) co-ordinate of the cetre point of the obstacle on the screen . |
el15ss | 3:0c690f1c04d8 | 53 | */ |
el15ss | 1:db9ff66f67c8 | 54 | Vector2D getObstaclePos(); |
el15ss | 3:0c690f1c04d8 | 55 | |
el15ss | 3:0c690f1c04d8 | 56 | /** Return Obstacle Status |
el15ss | 3:0c690f1c04d8 | 57 | * |
el15ss | 3:0c690f1c04d8 | 58 | * Returns the status of the obstacle which is sent to the main, where it is used to determine whether the obstacles have to be intialized or |
el15ss | 3:0c690f1c04d8 | 59 | * or renderd again. |
el15ss | 3:0c690f1c04d8 | 60 | */ |
el15ss | 1:db9ff66f67c8 | 61 | bool getObstacleStatus(); |
el15ss | 0:12cfe63faa6a | 62 | |
el15ss | 0:12cfe63faa6a | 63 | private: |
el15ss | 3:0c690f1c04d8 | 64 | |
el15ss | 3:0c690f1c04d8 | 65 | //Variables |
el15ss | 3:0c690f1c04d8 | 66 | int obsPosX; // X cocordinate of the obstacle |
el15ss | 3:0c690f1c04d8 | 67 | int obsPosY; // Y cocordinate of the obstacle |
el15ss | 3:0c690f1c04d8 | 68 | bool obStatus; //Variable to store the Obstacles status |
el15ss | 3:0c690f1c04d8 | 69 | |
el15ss | 0:12cfe63faa6a | 70 | |
el15ss | 0:12cfe63faa6a | 71 | }; |
el15ss | 0:12cfe63faa6a | 72 | #endif |