Kostadin Chakarov / Mbed 2 deprecated el17kec

Dependencies:   mbed

Committer:
kocemax
Date:
Wed May 08 23:09:43 2019 +0000
Revision:
9:f720f5d87420
Parent:
8:9b77eea95088
Child:
11:bb36db678a6d
I've finished the commenting and also added 1 new level, also added a score system. This is pretty much ready for submission now. Tomorrow might have a look again just to ensure everything is correct.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kocemax 6:39bda45efeed 1 #ifndef GAMEOBJECT_H
kocemax 6:39bda45efeed 2 #define GAMEOBJECT_H
kocemax 6:39bda45efeed 3
kocemax 6:39bda45efeed 4 #include "mbed.h"
kocemax 6:39bda45efeed 5 #include "N5110.h"
kocemax 6:39bda45efeed 6 #include "Gamepad.h"
kocemax 6:39bda45efeed 7
kocemax 6:39bda45efeed 8 /** GameObject Class
kocemax 6:39bda45efeed 9 @author Kostadin Chakarov, University of Leeds
kocemax 6:39bda45efeed 10 @brief Draws and controls the objects in the Breakout game, which can either be static or non-static
kocemax 6:39bda45efeed 11 @date April 2019
kocemax 6:39bda45efeed 12 */
kocemax 6:39bda45efeed 13
kocemax 6:39bda45efeed 14 class StaticGameObject
kocemax 6:39bda45efeed 15 {
kocemax 6:39bda45efeed 16 public:
kocemax 8:9b77eea95088 17 /** Constructor */
kocemax 6:39bda45efeed 18 StaticGameObject();
kocemax 8:9b77eea95088 19 /** Destructor */
kocemax 6:39bda45efeed 20 ~StaticGameObject();
kocemax 9:f720f5d87420 21 /** Controls the movement physics of static game objects: Does nothing but is overwritten in GameObject. */
kocemax 6:39bda45efeed 22 virtual void move();
kocemax 9:f720f5d87420 23 /** Draws the game object */
kocemax 6:39bda45efeed 24 virtual void draw(N5110 &lcd);
kocemax 9:f720f5d87420 25 /** Gets the x and y coordinates of game object */
kocemax 8:9b77eea95088 26 const Vector2D& getPos() const;
kocemax 9:f720f5d87420 27 /** Gets the width of the game object
kocemax 9:f720f5d87420 28 * @return the width of the game object
kocemax 8:9b77eea95088 29 */
kocemax 6:39bda45efeed 30 int getW() { return w; };
kocemax 9:f720f5d87420 31 /** Gets the height of the game object
kocemax 9:f720f5d87420 32 * @return the height of the game object
kocemax 8:9b77eea95088 33 */
kocemax 6:39bda45efeed 34 int getH() { return h; };
kocemax 8:9b77eea95088 35 /** Sets the width of any game object
kocemax 8:9b77eea95088 36 * @param value - sets the width of the game objects equal to it
kocemax 8:9b77eea95088 37 * @details Used for the power-up features
kocemax 8:9b77eea95088 38 */
kocemax 8:9b77eea95088 39 void setW(int value) { w = value;}
kocemax 6:39bda45efeed 40 protected:
kocemax 8:9b77eea95088 41 int w, h; /** width and height of any game object */
kocemax 9:f720f5d87420 42 Vector2D pos; /** x and y position of any game object */
kocemax 6:39bda45efeed 43 };
kocemax 6:39bda45efeed 44
kocemax 6:39bda45efeed 45
kocemax 6:39bda45efeed 46 class GameObject : public StaticGameObject
kocemax 6:39bda45efeed 47 {
kocemax 6:39bda45efeed 48 public:
kocemax 8:9b77eea95088 49 /** Constructor */
kocemax 8:9b77eea95088 50 GameObject() : StaticGameObject() {}
kocemax 9:f720f5d87420 51 /** Controls the movement physics of non-static game object */
kocemax 6:39bda45efeed 52 virtual void move();
kocemax 9:f720f5d87420 53 /** Gets the velocity of the game object
kocemax 9:f720f5d87420 54 * @return the velocity of the game object
kocemax 8:9b77eea95088 55 */
kocemax 7:cd3cafda3dd4 56 Vector2D& getVelocity() { return velocity; }
kocemax 6:39bda45efeed 57
kocemax 6:39bda45efeed 58 protected:
kocemax 9:f720f5d87420 59 Vector2D velocity; /** velocity of non-static game object */
kocemax 6:39bda45efeed 60 };
kocemax 6:39bda45efeed 61 #endif