Nemesis game, first enemy
Enemy1.h@7:3d951a743dbe, 2017-05-02 (annotated)
- Committer:
- musallambseiso
- Date:
- Tue May 02 22:13:59 2017 +0000
- Revision:
- 7:3d951a743dbe
- Child:
- 8:2ced844d8292
Added Doxygen, tidied code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
musallambseiso | 7:3d951a743dbe | 1 | #ifndef ENEMY1_H |
musallambseiso | 7:3d951a743dbe | 2 | #define ENEMY1_H |
musallambseiso | 7:3d951a743dbe | 3 | |
musallambseiso | 7:3d951a743dbe | 4 | #include "mbed.h" |
musallambseiso | 7:3d951a743dbe | 5 | #include "N5110.h" |
musallambseiso | 7:3d951a743dbe | 6 | #include "Gamepad.h" |
musallambseiso | 7:3d951a743dbe | 7 | #include "Friendly.h" |
musallambseiso | 7:3d951a743dbe | 8 | |
musallambseiso | 7:3d951a743dbe | 9 | class Enemy1 |
musallambseiso | 7:3d951a743dbe | 10 | { |
musallambseiso | 7:3d951a743dbe | 11 | |
musallambseiso | 7:3d951a743dbe | 12 | public: |
musallambseiso | 7:3d951a743dbe | 13 | |
musallambseiso | 7:3d951a743dbe | 14 | /// Constructor and destructor: |
musallambseiso | 7:3d951a743dbe | 15 | Enemy1(); |
musallambseiso | 7:3d951a743dbe | 16 | ~Enemy1(); |
musallambseiso | 7:3d951a743dbe | 17 | |
musallambseiso | 7:3d951a743dbe | 18 | |
musallambseiso | 7:3d951a743dbe | 19 | //////////////////////////////// |
musallambseiso | 7:3d951a743dbe | 20 | //////// PUBLIC METHODS |
musallambseiso | 7:3d951a743dbe | 21 | //////////////////////////////// |
musallambseiso | 7:3d951a743dbe | 22 | |
musallambseiso | 7:3d951a743dbe | 23 | |
musallambseiso | 7:3d951a743dbe | 24 | /** Initialize Enemy1 |
musallambseiso | 7:3d951a743dbe | 25 | * |
musallambseiso | 7:3d951a743dbe | 26 | * Initializes first enemy ship x (random) & y (fixed) positions, as well as speed. |
musallambseiso | 7:3d951a743dbe | 27 | */ |
musallambseiso | 7:3d951a743dbe | 28 | void init(int speed); |
musallambseiso | 7:3d951a743dbe | 29 | |
musallambseiso | 7:3d951a743dbe | 30 | |
musallambseiso | 7:3d951a743dbe | 31 | /** Draw Enemy1 |
musallambseiso | 7:3d951a743dbe | 32 | * |
musallambseiso | 7:3d951a743dbe | 33 | * Draws the first enemy ship onto the LCD, in accordance with the parameters initialized in the "init" method. |
musallambseiso | 7:3d951a743dbe | 34 | */ |
musallambseiso | 7:3d951a743dbe | 35 | void draw(N5110 &lcd); |
musallambseiso | 7:3d951a743dbe | 36 | |
musallambseiso | 7:3d951a743dbe | 37 | |
musallambseiso | 7:3d951a743dbe | 38 | /** Update Enemy1 |
musallambseiso | 7:3d951a743dbe | 39 | * |
musallambseiso | 7:3d951a743dbe | 40 | * Updates the first enemy ship's x and y position. X and y positions are altered by adding speeds. |
musallambseiso | 7:3d951a743dbe | 41 | */ |
musallambseiso | 7:3d951a743dbe | 42 | void update(); |
musallambseiso | 7:3d951a743dbe | 43 | |
musallambseiso | 7:3d951a743dbe | 44 | |
musallambseiso | 7:3d951a743dbe | 45 | /** Get Enemy1 Position |
musallambseiso | 7:3d951a743dbe | 46 | * |
musallambseiso | 7:3d951a743dbe | 47 | * Obtains the position (x and y coordinates) of the first enemy ship at any given time, into a two-dimensional vector. |
musallambseiso | 7:3d951a743dbe | 48 | * @returns p - the Vector2D of the parameters |
musallambseiso | 7:3d951a743dbe | 49 | */ |
musallambseiso | 7:3d951a743dbe | 50 | Vector2D get_pos(); |
musallambseiso | 7:3d951a743dbe | 51 | |
musallambseiso | 7:3d951a743dbe | 52 | private: |
musallambseiso | 7:3d951a743dbe | 53 | |
musallambseiso | 7:3d951a743dbe | 54 | |
musallambseiso | 7:3d951a743dbe | 55 | //////////////////////////////// |
musallambseiso | 7:3d951a743dbe | 56 | //////// PRIVATE VARIABLES |
musallambseiso | 7:3d951a743dbe | 57 | //////////////////////////////// |
musallambseiso | 7:3d951a743dbe | 58 | |
musallambseiso | 7:3d951a743dbe | 59 | |
musallambseiso | 7:3d951a743dbe | 60 | /// Vector2D that stores two speeds, one for x and one for y. |
musallambseiso | 7:3d951a743dbe | 61 | Vector2D _velocity; |
musallambseiso | 7:3d951a743dbe | 62 | |
musallambseiso | 7:3d951a743dbe | 63 | /// Integer variables to store the x and y coordinates of the friendly ship: |
musallambseiso | 7:3d951a743dbe | 64 | int _x; |
musallambseiso | 7:3d951a743dbe | 65 | int _y; |
musallambseiso | 7:3d951a743dbe | 66 | |
musallambseiso | 7:3d951a743dbe | 67 | }; |
musallambseiso | 7:3d951a743dbe | 68 | #endif |