Stick_Runner
Dependencies: FXOS8700CQ Gamepad N5110 SDFileSystem mbed
Character/Character.h@4:2fdafb53eac2, 2017-05-03 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15ss | 0:12cfe63faa6a | 1 | #ifndef Character_H |
el15ss | 0:12cfe63faa6a | 2 | #define Character_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 | 3:0c690f1c04d8 | 7 | /** Class Character |
el15ss | 3:0c690f1c04d8 | 8 | @brief Class responsible for all the functionality of the charachter 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 | 0:12cfe63faa6a | 14 | |
el15ss | 0:12cfe63faa6a | 15 | class Character |
el15ss | 0:12cfe63faa6a | 16 | { |
el15ss | 0:12cfe63faa6a | 17 | public: |
el15ss | 3:0c690f1c04d8 | 18 | /** Initialise display |
el15ss | 3:0c690f1c04d8 | 19 | * |
el15ss | 3:0c690f1c04d8 | 20 | * Powers up the display and turns on backlight (50% brightness default). |
el15ss | 3:0c690f1c04d8 | 21 | * Intialises the charchter status, x and y co-ordinate of the character. |
el15ss | 3:0c690f1c04d8 | 22 | */ |
el15ss | 0:12cfe63faa6a | 23 | void init(); |
el15ss | 3:0c690f1c04d8 | 24 | |
el15ss | 3:0c690f1c04d8 | 25 | /** Function to draw the character |
el15ss | 3:0c690f1c04d8 | 26 | * |
el15ss | 3:0c690f1c04d8 | 27 | * Draws the character to the display using the N5110 library and its object lcd. |
el15ss | 3:0c690f1c04d8 | 28 | * |
el15ss | 3:0c690f1c04d8 | 29 | */ |
el15ss | 0:12cfe63faa6a | 30 | void draw(N5110 &lcd); |
el15ss | 3:0c690f1c04d8 | 31 | |
el15ss | 3:0c690f1c04d8 | 32 | /** Updates/Moves Character |
el15ss | 3:0c690f1c04d8 | 33 | * |
el15ss | 3:0c690f1c04d8 | 34 | * Helps the charater move using the joystick. |
el15ss | 3:0c690f1c04d8 | 35 | * @param d - the direction from the joystick |
el15ss | 3:0c690f1c04d8 | 36 | * @param mag - initalses the speed of the character from the magnitude of the force on the joystick |
el15ss | 3:0c690f1c04d8 | 37 | */ |
el15ss | 1:db9ff66f67c8 | 38 | void updateCharacter(Direction d,float mag); |
el15ss | 3:0c690f1c04d8 | 39 | |
el15ss | 4:2fdafb53eac2 | 40 | /** Character Status |
el15ss | 3:0c690f1c04d8 | 41 | * |
el15ss | 3:0c690f1c04d8 | 42 | * This fuction helps to check if there are any obstacles/gems around the character on the screen |
el15ss | 3:0c690f1c04d8 | 43 | * . It checks if any pixels near the body dimensions of the character are lit up and sets the status of the character to false |
el15ss | 3:0c690f1c04d8 | 44 | * if any. |
el15ss | 3:0c690f1c04d8 | 45 | * @param p - stores the 2D location i.e. the (x,y) co-ordinate of the cetre point of the character on the screen . |
el15ss | 3:0c690f1c04d8 | 46 | */ |
el15ss | 1:db9ff66f67c8 | 47 | void characterStatus(Vector2D p); |
el15ss | 3:0c690f1c04d8 | 48 | |
el15ss | 3:0c690f1c04d8 | 49 | /** Character Position |
el15ss | 3:0c690f1c04d8 | 50 | * |
el15ss | 3:0c690f1c04d8 | 51 | * Returns the 2D location i.e. the (x,y) co-ordinate of the cetre point of the character on the screen . |
el15ss | 3:0c690f1c04d8 | 52 | */ |
el15ss | 1:db9ff66f67c8 | 53 | Vector2D getCharacterPos(); |
el15ss | 3:0c690f1c04d8 | 54 | |
el15ss | 3:0c690f1c04d8 | 55 | |
el15ss | 3:0c690f1c04d8 | 56 | /** Return Character Status |
el15ss | 3:0c690f1c04d8 | 57 | * |
el15ss | 3:0c690f1c04d8 | 58 | * Returns the status of the character which is sent to the main, where it is used to determine whether the character |
el15ss | 3:0c690f1c04d8 | 59 | * should be drawn. If true, the character is drwan else not. |
el15ss | 3:0c690f1c04d8 | 60 | */ |
el15ss | 1:db9ff66f67c8 | 61 | bool getCharacterStatus(); |
el15ss | 0:12cfe63faa6a | 62 | |
el15ss | 0:12cfe63faa6a | 63 | private: |
el15ss | 0:12cfe63faa6a | 64 | |
el15ss | 4:2fdafb53eac2 | 65 | //Variables |
el15ss | 3:0c690f1c04d8 | 66 | int charPosX; // X cocordinate of the character |
el15ss | 3:0c690f1c04d8 | 67 | int charPosY; // Y cocordinate of the character |
el15ss | 3:0c690f1c04d8 | 68 | int _speed; //Variable to help determine the speed of the character from the magnitude of the joystick |
el15ss | 3:0c690f1c04d8 | 69 | |
el15ss | 3:0c690f1c04d8 | 70 | bool charStatus; //Variable to store the Cgaracters status |
el15ss | 3:0c690f1c04d8 | 71 | |
el15ss | 0:12cfe63faa6a | 72 | |
el15ss | 0:12cfe63faa6a | 73 | }; |
el15ss | 0:12cfe63faa6a | 74 | #endif |