Matis Requis 201241242

Dependencies:   mbed

Tempest Game

Game Screen

https://os.mbed.com/media/uploads/MatisRequis/tempest_board_wiki.png The board is made of 12 columns. The Hero stays at the top of the column

Game Controls

https://os.mbed.com/media/uploads/MatisRequis/gamepad_buttons.png

To control the hero spaceship point the joystick to the column you want the hero to go to.

Press the A button to shoot a bullet in the column you are currently in.

Committer:
MatisRequis
Date:
Tue May 26 16:31:22 2020 +0000
Revision:
10:2ae9d4145410
Parent:
9:759b419fec3b
Finished code with comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MatisRequis 9:759b419fec3b 1 #ifndef Alien_H
MatisRequis 9:759b419fec3b 2 #define Alien_H
MatisRequis 9:759b419fec3b 3
MatisRequis 10:2ae9d4145410 4 // Included Libraries
MatisRequis 9:759b419fec3b 5 #include "mbed.h"
MatisRequis 9:759b419fec3b 6 #include "N5110.h"
MatisRequis 9:759b419fec3b 7 #include "Gamepad.h"
MatisRequis 9:759b419fec3b 8 #include "Board.h"
MatisRequis 9:759b419fec3b 9
MatisRequis 9:759b419fec3b 10 #include <cstdlib>
MatisRequis 9:759b419fec3b 11 #include <ctime>
MatisRequis 9:759b419fec3b 12
MatisRequis 10:2ae9d4145410 13 /** Alien Class
MatisRequis 10:2ae9d4145410 14 * @brief Draws and moves the aliens
MatisRequis 10:2ae9d4145410 15 * @author Matis Requis
MatisRequis 10:2ae9d4145410 16 * @date May, 2020
MatisRequis 10:2ae9d4145410 17 */
MatisRequis 9:759b419fec3b 18 class Alien {
MatisRequis 9:759b419fec3b 19 public:
MatisRequis 10:2ae9d4145410 20
MatisRequis 10:2ae9d4145410 21 /** Constructor */
MatisRequis 9:759b419fec3b 22 Alien();
MatisRequis 10:2ae9d4145410 23
MatisRequis 10:2ae9d4145410 24 /** Destructor */
MatisRequis 9:759b419fec3b 25 ~Alien();
MatisRequis 10:2ae9d4145410 26
MatisRequis 10:2ae9d4145410 27 /** Initialises the bullet
MatisRequis 10:2ae9d4145410 28 * @param column @details column the bullet spawns at
MatisRequis 10:2ae9d4145410 29 * @param speed @details speed at which the alien moves lower is faster
MatisRequis 10:2ae9d4145410 30 */
MatisRequis 9:759b419fec3b 31 void init(int column, int speed);
MatisRequis 10:2ae9d4145410 32
MatisRequis 10:2ae9d4145410 33
MatisRequis 10:2ae9d4145410 34 /** Draws the alien
MatisRequis 10:2ae9d4145410 35 * @param lcd @details N5110 object
MatisRequis 10:2ae9d4145410 36 */
MatisRequis 9:759b419fec3b 37 void draw(N5110 &lcd);
MatisRequis 10:2ae9d4145410 38
MatisRequis 10:2ae9d4145410 39 /** Updates the aliens location */
MatisRequis 9:759b419fec3b 40 void update();
MatisRequis 10:2ae9d4145410 41
MatisRequis 10:2ae9d4145410 42 /** checks if the alien needs to be deleted
MatisRequis 10:2ae9d4145410 43 * @return 1 or 0 @details returns 1 if alien needs to be deleted
MatisRequis 10:2ae9d4145410 44 */
MatisRequis 9:759b419fec3b 45 int checkdelete();
MatisRequis 10:2ae9d4145410 46
MatisRequis 10:2ae9d4145410 47 /** checks if the alien need has reached the top of the board */
MatisRequis 9:759b419fec3b 48 int checkobjective();
MatisRequis 10:2ae9d4145410 49
MatisRequis 10:2ae9d4145410 50
MatisRequis 10:2ae9d4145410 51 /** returns a vector with the alien position
MatisRequis 10:2ae9d4145410 52 * @return alienxy @details Vector2D structure with the aliens xy coordinates
MatisRequis 10:2ae9d4145410 53 */
MatisRequis 9:759b419fec3b 54 Vector2D getxy();
MatisRequis 9:759b419fec3b 55
MatisRequis 10:2ae9d4145410 56 /** returns a vector with the alien lane and position
MatisRequis 10:2ae9d4145410 57 * @return aliencolpos @details Vector2D structure with the aliens lane and position
MatisRequis 10:2ae9d4145410 58 */
MatisRequis 10:2ae9d4145410 59 Vector2D getcolumnpos();
MatisRequis 10:2ae9d4145410 60
MatisRequis 9:759b419fec3b 61 private:
MatisRequis 9:759b419fec3b 62 int _column;
MatisRequis 9:759b419fec3b 63 int _x;
MatisRequis 9:759b419fec3b 64 int _y;
MatisRequis 9:759b419fec3b 65 Board _board;
MatisRequis 9:759b419fec3b 66 int _currentpos;
MatisRequis 9:759b419fec3b 67 int _rand;
MatisRequis 9:759b419fec3b 68 int _movcount;
MatisRequis 9:759b419fec3b 69 int _alienspeed;
MatisRequis 9:759b419fec3b 70 };
MatisRequis 9:759b419fec3b 71 #endif