Nemesis game, friendly

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Friendly.h Source File

Friendly.h

00001 #ifndef FRIENDLY_H
00002 #define FRIENDLY_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 /** Friendly Class
00009 @brief Used for controlling the friendly ship in the Nemesis game. Includes drawing, checking, and updating functions. 
00010 @brief Incorporates N5110.h and Gamepad.h files by Craig A. Evans.
00011 
00012 @brief Revision 1.0
00013 
00014 @author Musallam M. M. Bseiso
00015 @date   3rd May 2017
00016 */
00017 
00018 
00019 class Friendly
00020 {
00021 public:
00022     
00023     /// Constructor and destructor:
00024     Friendly();
00025     ~Friendly();
00026     
00027     
00028     ////////////////////////////////
00029     //////// PUBLIC METHODS
00030     ////////////////////////////////
00031     
00032     
00033     /** Initialize Friendly
00034     *   
00035     *   Initializes friendly ship x & y positions.
00036     */
00037     void init();
00038     
00039     
00040     /** Draw Friendly
00041     *   
00042     *   Draws the friendly ship onto the LCD, in accordance with the parameters initialized in the "init" method.
00043     *   @param N5110 - nokia LCD library
00044     *   @param lcd - pointer to nokia LCD library
00045     */
00046     void draw(N5110 &lcd);
00047     
00048     
00049     /** Update Friendly (basic)
00050     *   
00051     *   Updates the friendly ship's x and y position. X and y positions are altered by adding/subtracting speeds,
00052     *   which depend on the direction (d) of the analog stick. The speed is defined as the magnitude of the movement
00053     *   of the analog stick multiplied by an arbitrary number (set as 4). This method only deals with the basic 
00054     *   horizontal and vertical movements of the friendly ship (North, South, West, East).
00055     *   @param d - direction of analog stick
00056     *   @param mag - magnitude of movement of analog stick
00057     */
00058     void update_basic(Direction d,float mag);
00059     
00060     
00061     /** Update Friendly (diagonal)
00062     *   
00063     *   Updates the friendly ship's x and y position. X and y positions are altered by adding/subtracting speeds,
00064     *   which depend on the direction (d) of the analog stick. The speed is defined as the magnitude of the movement
00065     *   of the analog stick multiplied by an arbitrary number (set as 4). This method only deals with the diagonal 
00066     *   movements of the friendly ship (Northwest, Northeast, Southwest, Southeast).
00067     *   @param d - direction of analog stick
00068     *   @param mag - magnitude of movement of analog stick
00069     */
00070     void update_diagonal(Direction d,float mag);
00071     
00072     
00073     /** Check Friendly Position
00074     *
00075     *   Ensures the friendly ship does not go out of bounds (off screen or into the stats bar) by limiting its x and
00076     *   y positions.
00077     */
00078     void check_pos();
00079     
00080     
00081     /** Get Friendly Position
00082     *
00083     *   Obtains the position (x and y coordinates) of the friendly ship at any given time, into a two-dimensional vector.
00084     *   @returns p - the Vector2D of the parameters
00085     */
00086     Vector2D get_pos();
00087 
00088 private:
00089     
00090     
00091     ////////////////////////////////
00092     //////// PRIVATE VARIABLES
00093     ////////////////////////////////
00094     
00095     int _speed;
00096     
00097     /// Integer variables to store the x and y coordinates of the friendly ship:
00098     int _x;
00099     int _y;
00100 
00101 };
00102 #endif