Nemesis game, friendly

Committer:
musallambseiso
Date:
Wed May 03 20:02:57 2017 +0000
Revision:
11:4c4a0fe18ac2
Parent:
10:b856d73db923
Removed redundant code, perfected Doxygen, added inline comments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
musallambseiso 4:879c4cb8a7e4 1 #ifndef FRIENDLY_H
musallambseiso 4:879c4cb8a7e4 2 #define FRIENDLY_H
musallambseiso 4:879c4cb8a7e4 3
musallambseiso 4:879c4cb8a7e4 4 #include "mbed.h"
musallambseiso 4:879c4cb8a7e4 5 #include "N5110.h"
musallambseiso 4:879c4cb8a7e4 6 #include "Gamepad.h"
musallambseiso 4:879c4cb8a7e4 7
musallambseiso 11:4c4a0fe18ac2 8 /** Friendly Class
musallambseiso 11:4c4a0fe18ac2 9 @brief Used for controlling the friendly ship in the Nemesis game. Includes drawing, checking, and updating functions.
musallambseiso 11:4c4a0fe18ac2 10 @brief Incorporates N5110.h and Gamepad.h files by Craig A. Evans.
musallambseiso 11:4c4a0fe18ac2 11
musallambseiso 11:4c4a0fe18ac2 12 @brief Revision 1.0
musallambseiso 11:4c4a0fe18ac2 13
musallambseiso 11:4c4a0fe18ac2 14 @author Musallam M. M. Bseiso
musallambseiso 11:4c4a0fe18ac2 15 @date 3rd May 2017
musallambseiso 11:4c4a0fe18ac2 16 */
musallambseiso 11:4c4a0fe18ac2 17
musallambseiso 11:4c4a0fe18ac2 18
musallambseiso 4:879c4cb8a7e4 19 class Friendly
musallambseiso 4:879c4cb8a7e4 20 {
musallambseiso 4:879c4cb8a7e4 21 public:
musallambseiso 10:b856d73db923 22
musallambseiso 10:b856d73db923 23 /// Constructor and destructor:
musallambseiso 4:879c4cb8a7e4 24 Friendly();
musallambseiso 4:879c4cb8a7e4 25 ~Friendly();
musallambseiso 10:b856d73db923 26
musallambseiso 10:b856d73db923 27
musallambseiso 10:b856d73db923 28 ////////////////////////////////
musallambseiso 10:b856d73db923 29 //////// PUBLIC METHODS
musallambseiso 10:b856d73db923 30 ////////////////////////////////
musallambseiso 10:b856d73db923 31
musallambseiso 10:b856d73db923 32
musallambseiso 10:b856d73db923 33 /** Initialize Friendly
musallambseiso 10:b856d73db923 34 *
musallambseiso 10:b856d73db923 35 * Initializes friendly ship x & y positions.
musallambseiso 10:b856d73db923 36 */
musallambseiso 9:3c411d37d390 37 void init();
musallambseiso 10:b856d73db923 38
musallambseiso 10:b856d73db923 39
musallambseiso 10:b856d73db923 40 /** Draw Friendly
musallambseiso 10:b856d73db923 41 *
musallambseiso 10:b856d73db923 42 * Draws the friendly ship onto the LCD, in accordance with the parameters initialized in the "init" method.
musallambseiso 11:4c4a0fe18ac2 43 * @param N5110 - nokia LCD library
musallambseiso 11:4c4a0fe18ac2 44 * @param lcd - pointer to nokia LCD library
musallambseiso 10:b856d73db923 45 */
musallambseiso 4:879c4cb8a7e4 46 void draw(N5110 &lcd);
musallambseiso 10:b856d73db923 47
musallambseiso 10:b856d73db923 48
musallambseiso 11:4c4a0fe18ac2 49 /** Update Friendly (basic)
musallambseiso 10:b856d73db923 50 *
musallambseiso 10:b856d73db923 51 * Updates the friendly ship's x and y position. X and y positions are altered by adding/subtracting speeds,
musallambseiso 10:b856d73db923 52 * which depend on the direction (d) of the analog stick. The speed is defined as the magnitude of the movement
musallambseiso 11:4c4a0fe18ac2 53 * of the analog stick multiplied by an arbitrary number (set as 4). This method only deals with the basic
musallambseiso 11:4c4a0fe18ac2 54 * horizontal and vertical movements of the friendly ship (North, South, West, East).
musallambseiso 10:b856d73db923 55 * @param d - direction of analog stick
musallambseiso 10:b856d73db923 56 * @param mag - magnitude of movement of analog stick
musallambseiso 10:b856d73db923 57 */
musallambseiso 11:4c4a0fe18ac2 58 void update_basic(Direction d,float mag);
musallambseiso 11:4c4a0fe18ac2 59
musallambseiso 11:4c4a0fe18ac2 60
musallambseiso 11:4c4a0fe18ac2 61 /** Update Friendly (diagonal)
musallambseiso 11:4c4a0fe18ac2 62 *
musallambseiso 11:4c4a0fe18ac2 63 * Updates the friendly ship's x and y position. X and y positions are altered by adding/subtracting speeds,
musallambseiso 11:4c4a0fe18ac2 64 * which depend on the direction (d) of the analog stick. The speed is defined as the magnitude of the movement
musallambseiso 11:4c4a0fe18ac2 65 * of the analog stick multiplied by an arbitrary number (set as 4). This method only deals with the diagonal
musallambseiso 11:4c4a0fe18ac2 66 * movements of the friendly ship (Northwest, Northeast, Southwest, Southeast).
musallambseiso 11:4c4a0fe18ac2 67 * @param d - direction of analog stick
musallambseiso 11:4c4a0fe18ac2 68 * @param mag - magnitude of movement of analog stick
musallambseiso 11:4c4a0fe18ac2 69 */
musallambseiso 11:4c4a0fe18ac2 70 void update_diagonal(Direction d,float mag);
musallambseiso 10:b856d73db923 71
musallambseiso 10:b856d73db923 72
musallambseiso 10:b856d73db923 73 /** Check Friendly Position
musallambseiso 10:b856d73db923 74 *
musallambseiso 10:b856d73db923 75 * Ensures the friendly ship does not go out of bounds (off screen or into the stats bar) by limiting its x and
musallambseiso 10:b856d73db923 76 * y positions.
musallambseiso 10:b856d73db923 77 */
musallambseiso 10:b856d73db923 78 void check_pos();
musallambseiso 10:b856d73db923 79
musallambseiso 10:b856d73db923 80
musallambseiso 10:b856d73db923 81 /** Get Friendly Position
musallambseiso 10:b856d73db923 82 *
musallambseiso 10:b856d73db923 83 * Obtains the position (x and y coordinates) of the friendly ship at any given time, into a two-dimensional vector.
musallambseiso 10:b856d73db923 84 * @returns p - the Vector2D of the parameters
musallambseiso 10:b856d73db923 85 */
musallambseiso 4:879c4cb8a7e4 86 Vector2D get_pos();
musallambseiso 4:879c4cb8a7e4 87
musallambseiso 4:879c4cb8a7e4 88 private:
musallambseiso 10:b856d73db923 89
musallambseiso 10:b856d73db923 90
musallambseiso 10:b856d73db923 91 ////////////////////////////////
musallambseiso 10:b856d73db923 92 //////// PRIVATE VARIABLES
musallambseiso 10:b856d73db923 93 ////////////////////////////////
musallambseiso 10:b856d73db923 94
musallambseiso 10:b856d73db923 95 int _speed;
musallambseiso 10:b856d73db923 96
musallambseiso 10:b856d73db923 97 /// Integer variables to store the x and y coordinates of the friendly ship:
musallambseiso 4:879c4cb8a7e4 98 int _x;
musallambseiso 4:879c4cb8a7e4 99 int _y;
musallambseiso 4:879c4cb8a7e4 100
musallambseiso 4:879c4cb8a7e4 101 };
musallambseiso 4:879c4cb8a7e4 102 #endif