Stick_Runner

Dependencies:   FXOS8700CQ Gamepad N5110 SDFileSystem mbed

Fork of Stick_Runner by Samrudh Sharma

Committer:
el15ss
Date:
Wed May 03 09:27:04 2017 +0000
Revision:
3:0c690f1c04d8
Parent:
2:98a41609c827
Child:
4:2fdafb53eac2
Added DOxygen commenting to all files

Who changed what in which revision?

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