Stick_Runner

Dependencies:   FXOS8700CQ Gamepad N5110 SDFileSystem mbed

Fork of Stick_Runner by Samrudh Sharma

Committer:
el15ss
Date:
Thu May 04 14:11:18 2017 +0000
Revision:
7:887651afda26
Parent:
6:bf601a65cb27
StickRunner v1.0

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 7:887651afda26 7
el15ss 6:bf601a65cb27 8
el15ss 3:0c690f1c04d8 9 /** Class Character
el15ss 3:0c690f1c04d8 10 @brief Class responsible for all the functionality of the charachter including intialization, drawing, moving and updating it
el15ss 3:0c690f1c04d8 11 @author Samrudh Sharma
el15ss 3:0c690f1c04d8 12 @date
el15ss 4:2fdafb53eac2 13 @classes
el15ss 3:0c690f1c04d8 14 */
el15ss 3:0c690f1c04d8 15
el15ss 0:12cfe63faa6a 16
el15ss 0:12cfe63faa6a 17 class Character
el15ss 0:12cfe63faa6a 18 {
el15ss 0:12cfe63faa6a 19 public:
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 character.
el15ss 3:0c690f1c04d8 24 */
el15ss 0:12cfe63faa6a 25 void init();
el15ss 3:0c690f1c04d8 26
el15ss 3:0c690f1c04d8 27 /** Function to draw the character
el15ss 3:0c690f1c04d8 28 *
el15ss 3:0c690f1c04d8 29 * Draws the character 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 Character
el15ss 3:0c690f1c04d8 35 *
el15ss 3:0c690f1c04d8 36 * Helps the charater move using the joystick.
el15ss 3:0c690f1c04d8 37 * @param d - the direction from the joystick
el15ss 3:0c690f1c04d8 38 * @param mag - initalses the speed of the character from the magnitude of the force on the joystick
el15ss 3:0c690f1c04d8 39 */
el15ss 1:db9ff66f67c8 40 void updateCharacter(Direction d,float mag);
el15ss 3:0c690f1c04d8 41
el15ss 4:2fdafb53eac2 42 /** Character Status
el15ss 3:0c690f1c04d8 43 *
el15ss 3:0c690f1c04d8 44 * This fuction helps to check if there are any obstacles/gems around the character on the screen
el15ss 3:0c690f1c04d8 45 * . 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 46 * if any.
el15ss 3:0c690f1c04d8 47 * @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 48 */
el15ss 1:db9ff66f67c8 49 void characterStatus(Vector2D p);
el15ss 3:0c690f1c04d8 50
el15ss 3:0c690f1c04d8 51 /** Character Position
el15ss 3:0c690f1c04d8 52 *
el15ss 3:0c690f1c04d8 53 * Returns the 2D location i.e. the (x,y) co-ordinate of the cetre point of the character on the screen .
el15ss 3:0c690f1c04d8 54 */
el15ss 1:db9ff66f67c8 55 Vector2D getCharacterPos();
el15ss 3:0c690f1c04d8 56
el15ss 3:0c690f1c04d8 57
el15ss 3:0c690f1c04d8 58 /** Return Character Status
el15ss 3:0c690f1c04d8 59 *
el15ss 3:0c690f1c04d8 60 * Returns the status of the character which is sent to the main, where it is used to determine whether the character
el15ss 3:0c690f1c04d8 61 * should be drawn. If true, the character is drwan else not.
el15ss 3:0c690f1c04d8 62 */
el15ss 1:db9ff66f67c8 63 bool getCharacterStatus();
el15ss 0:12cfe63faa6a 64
el15ss 6:bf601a65cb27 65
el15ss 6:bf601a65cb27 66
el15ss 0:12cfe63faa6a 67 private:
el15ss 0:12cfe63faa6a 68
el15ss 4:2fdafb53eac2 69 //Variables
el15ss 3:0c690f1c04d8 70 int charPosX; // X cocordinate of the character
el15ss 3:0c690f1c04d8 71 int charPosY; // Y cocordinate of the character
el15ss 3:0c690f1c04d8 72 int _speed; //Variable to help determine the speed of the character from the magnitude of the joystick
el15ss 3:0c690f1c04d8 73
el15ss 3:0c690f1c04d8 74 bool charStatus; //Variable to store the Cgaracters status
el15ss 3:0c690f1c04d8 75
el15ss 0:12cfe63faa6a 76
el15ss 0:12cfe63faa6a 77 };
el15ss 0:12cfe63faa6a 78 #endif