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