ELEC2645 (2018/19) / Mbed 2 deprecated el17ntkv

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Ghost.h Source File

Ghost.h

00001 #ifndef GHOST_H
00002 #define GHOST_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 #include "ScreenArray.h"
00008 #include<cmath>
00009 
00010 
00011 /** Ghost Class
00012 @author Mr Nigel TK Vere, University of Leeds
00013 @brief Controls and models the ghost  character for the badman game
00014 @date April 2019
00015 */
00016 
00017 /** Ghost Class
00018 
00019 @brief Controls and models the ghost character for the badman game
00020 
00021 @version 1.0
00022 
00023 @author Mr Nigel TK Vere
00024 
00025 @date April 2019
00026 
00027 
00028 */
00029 
00030 class Ghost
00031 {
00032 
00033 public:
00034 
00035     /**
00036     * @brief Default Ghost object constructor
00037 
00038     */
00039     Ghost();
00040     /**
00041     * @brief Default Ghost object destructor
00042 
00043     */
00044     ~Ghost();
00045     /**
00046     * @brief Mutator method initialises the ghost character object setting it's radius and start position in the maze
00047     * @param size @details Integer value giving the radius of the ghost object
00048     * @param x @details Integer value giving the x coordinate  of the ghost object
00049     * @param y @details Integer value giving the y coordinate  of the ghost object
00050     */
00051     void init(int size,int x,int y);
00052     /**
00053     * @brief Mutator method displays the ghost character on the lcd screen dependent on it's current x and y coordinates and size
00054     * @param lcd @details Reference Nokia 5110 LCD screen object
00055     */
00056     void draw(N5110 &lcd);
00057     /**
00058     * @brief Accessor method checks whether the ghost object has collided with the badman character object
00059     * @param x @details Integer value giving the x coordinate  of the badman character object
00060     * @param y @details Integer value giving the y coordinate  of the badman character object
00061      * @param r @details Integer value giving the radius of the badman character object
00062       @returns Returns a boolean value notifying whether a ghost-badman collision has occured
00063     */
00064     bool collisiondetection(int x,int y,int r);
00065     /**
00066     * @brief Accessor method gets the current coordinates of the ghost character object
00067     @returns Returns the Vector data type holding the current x and y coordinates of the ghost character object's centre
00068     */
00069     Vector2D getPos();
00070     /**
00071     * @brief Mutator method updates the ghost object's movement in the instance that the ghost has collided with a wall
00072     * @param screen @details Reference screen array object for the ghost object collision detection
00073     */
00074     void update(ScreenArray &screen);
00075 
00076     /**
00077     * @brief Accessor method checks ghost-wall collisions
00078     @returns Returns an integer value notifying the type of object the ghost has collided with as it moves
00079     */
00080     int checkCollision(ScreenArray &screen);
00081 
00082     /**
00083       * @brief Mutator method gets the current x and y coordinate of the ghost object to the coordinate passed in the function call
00084       * @param x @details X coordinate value of the new position the ghost character object is to move to
00085       * @param y @details Y coordinate value of the new position the ghost character object is to move to
00086       */
00087     void setPos(int x, int y);
00088 
00089     /**
00090     * @brief Accessor method gets the size of badman character object
00091     @returns Returns the size(radius ) of the badman character object
00092     */
00093     int getSize();
00094 
00095 
00096 
00097 
00098 private:
00099     int _x;//Integer value represents the x coordinate of the ghost character
00100     int _y;//Integer value represents the y coordinate of the ghost character
00101     int _direction;//Integer value represents the direction of movement of the ghost character
00102     int _size;//Integer value represents radius of the ghost character
00103     Vector2D _topr;
00104     Vector2D _bottr;
00105     Vector2D _bottl;
00106     Vector2D _topl;
00107 };
00108 #endif