ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

Committer:
fy14lkaa
Date:
Mon Apr 22 13:17:23 2019 +0000
Revision:
50:f538885a788b
Parent:
49:5b797f126e5c
Child:
51:cb644365d9a3
added comments to space_ship.h to explain the public (accessors and mutators methods) and private (member variables) of space_ship class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fy14lkaa 34:4bff5515060e 1 #ifndef SPACE_SHIP_H
fy14lkaa 34:4bff5515060e 2 #define SPACE_SHIP_H
fy14lkaa 34:4bff5515060e 3
fy14lkaa 34:4bff5515060e 4 #include "mbed.h"
fy14lkaa 34:4bff5515060e 5 #include "N5110.h"
fy14lkaa 34:4bff5515060e 6 #include "Gamepad.h"
fy14lkaa 35:261df7c3a3fb 7 #include "SpaceInvadersEngine.h"
fy14lkaa 35:261df7c3a3fb 8 #include "Alien.h"
fy14lkaa 35:261df7c3a3fb 9 #include "bullet.h"
fy14lkaa 34:4bff5515060e 10
fy14lkaa 50:f538885a788b 11 /** space_ship class
fy14lkaa 50:f538885a788b 12 @brief class for spaceship
fy14lkaa 50:f538885a788b 13 @version 1.0
fy14lkaa 50:f538885a788b 14 @author Laila Al Badwawi
fy14lkaa 50:f538885a788b 15 @date April 2019
fy14lkaa 50:f538885a788b 16 */
fy14lkaa 50:f538885a788b 17
fy14lkaa 36:9bb204e390c5 18 class space_ship
fy14lkaa 36:9bb204e390c5 19 {
fy14lkaa 37:b2ced2de074b 20
fy14lkaa 37:b2ced2de074b 21 public:
fy14lkaa 50:f538885a788b 22 // constructors
fy14lkaa 50:f538885a788b 23 //string Variables of this type are able to store sequences of characters,
fy14lkaa 50:f538885a788b 24 //such as words or sentences.
fy14lkaa 50:f538885a788b 25 /**
fy14lkaa 50:f538885a788b 26 *@constucter creat a defult a spaceship
fy14lkaa 50:f538885a788b 27 */
fy14lkaa 50:f538885a788b 28 space_ship(); //constructor
fy14lkaa 50:f538885a788b 29
fy14lkaa 50:f538885a788b 30
fy14lkaa 50:f538885a788b 31 ~space_ship(); //descontractor
fy14lkaa 37:b2ced2de074b 32
fy14lkaa 50:f538885a788b 33
fy14lkaa 50:f538885a788b 34 /*mutators
fy14lkaa 50:f538885a788b 35 //mutator methods defined as methods which advice the users of the class
fy14lkaa 50:f538885a788b 36 //to change the value of a member variable in a controlled manner.
fy14lkaa 50:f538885a788b 37 Their names are usually pre-fixed with set_ to make this behaviour clear.*/
fy14lkaa 50:f538885a788b 38
fy14lkaa 50:f538885a788b 39
fy14lkaa 50:f538885a788b 40
fy14lkaa 50:f538885a788b 41 void init(int x,int height,int width); // a mutotor method used to set the following variables (x-cooridante, height and width).
fy14lkaa 50:f538885a788b 42 void draw(N5110 &lcd); // a mutotor method used to set the the drawing variable to draw the space ship by using both N5110&lcd libraries.
fy14lkaa 50:f538885a788b 43 void update(Direction d,float mag); // a mutotor method used to update the direction of the spaceship and its speed(magniutde).
fy14lkaa 50:f538885a788b 44 void add_score(); // a mutotor method used to add the scores of the spaceship.everytime the buliet fires the alien so it inceased the number of scores by 1.
fy14lkaa 50:f538885a788b 45
fy14lkaa 50:f538885a788b 46
fy14lkaa 50:f538885a788b 47
fy14lkaa 50:f538885a788b 48
fy14lkaa 50:f538885a788b 49
fy14lkaa 50:f538885a788b 50 /*accessors
fy14lkaa 50:f538885a788b 51 An accessor method defined as methods which help users to read the value of a member variable.
fy14lkaa 50:f538885a788b 52 Their names are usually prefixed with get_ to make this clearer to the user.
fy14lkaa 50:f538885a788b 53 */
fy14lkaa 50:f538885a788b 54
fy14lkaa 50:f538885a788b 55
fy14lkaa 50:f538885a788b 56 int get_score(); // an accessor method used to return the number of tne scores.
fy14lkaa 50:f538885a788b 57 Vector2D get_pos(); // an accessor method used to return the position of the spaceship in vector2D.
fy14lkaa 44:0b0d31dc3d05 58
fy14lkaa 44:0b0d31dc3d05 59 private:
fy14lkaa 50:f538885a788b 60 //member variables
fy14lkaa 50:f538885a788b 61 //parameters
fy14lkaa 44:0b0d31dc3d05 62
fy14lkaa 50:f538885a788b 63 /*@param
fy14lkaa 50:f538885a788b 64 _height
fy14lkaa 50:f538885a788b 65 */
fy14lkaa 50:f538885a788b 66 int _height; // declation of a variable member _width which shows the height of the spaceship.
fy14lkaa 50:f538885a788b 67 /*@param
fy14lkaa 50:f538885a788b 68 _wedith
fy14lkaa 50:f538885a788b 69 */
fy14lkaa 50:f538885a788b 70
fy14lkaa 50:f538885a788b 71 int _width; // declation of a variable member _width which shows the width of the spaceship.
fy14lkaa 50:f538885a788b 72 //@param
fy14lkaa 50:f538885a788b 73 //_x
fy14lkaa 50:f538885a788b 74 int _x; //declation of a variable member _width which shows the x-cooridante of the spaceship.
fy14lkaa 50:f538885a788b 75 /*@param
fy14lkaa 50:f538885a788b 76 _y
fy14lkaa 50:f538885a788b 77 */
fy14lkaa 50:f538885a788b 78 int _y; //declation of a variable member _width which shows the y-cooridante of the spaceship.
fy14lkaa 50:f538885a788b 79 /*@param
fy14lkaa 50:f538885a788b 80 _speed
fy14lkaa 50:f538885a788b 81 */
fy14lkaa 50:f538885a788b 82 int _speed; // declation of a variable member _width which shows the speed of the spaceship.
fy14lkaa 50:f538885a788b 83 /*@param
fy14lkaa 50:f538885a788b 84 _score
fy14lkaa 50:f538885a788b 85 */
fy14lkaa 50:f538885a788b 86 int _score; // declation of a variable member _width which shows the speed of the spaceship.
fy14lkaa 50:f538885a788b 87
fy14lkaa 44:0b0d31dc3d05 88
fy14lkaa 44:0b0d31dc3d05 89 };
fy14lkaa 50:f538885a788b 90
fy14lkaa 44:0b0d31dc3d05 91 #endif
fy14lkaa 34:4bff5515060e 92
fy14lkaa 34:4bff5515060e 93
fy14lkaa 34:4bff5515060e 94
fy14lkaa 34:4bff5515060e 95
fy14lkaa 34:4bff5515060e 96
fy14lkaa 34:4bff5515060e 97
fy14lkaa 34:4bff5515060e 98
fy14lkaa 34:4bff5515060e 99
fy14lkaa 34:4bff5515060e 100
fy14lkaa 34:4bff5515060e 101
fy14lkaa 34:4bff5515060e 102
fy14lkaa 34:4bff5515060e 103
fy14lkaa 34:4bff5515060e 104
fy14lkaa 34:4bff5515060e 105
fy14lkaa 34:4bff5515060e 106
fy14lkaa 34:4bff5515060e 107
fy14lkaa 34:4bff5515060e 108
fy14lkaa 34:4bff5515060e 109
fy14lkaa 34:4bff5515060e 110
fy14lkaa 34:4bff5515060e 111
fy14lkaa 34:4bff5515060e 112
fy14lkaa 34:4bff5515060e 113
fy14lkaa 34:4bff5515060e 114
fy14lkaa 34:4bff5515060e 115
fy14lkaa 34:4bff5515060e 116
fy14lkaa 34:4bff5515060e 117
fy14lkaa 34:4bff5515060e 118
fy14lkaa 34:4bff5515060e 119
fy14lkaa 34:4bff5515060e 120
fy14lkaa 34:4bff5515060e 121
fy14lkaa 34:4bff5515060e 122
fy14lkaa 34:4bff5515060e 123
fy14lkaa 34:4bff5515060e 124