Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GameObject/GameObject.h@8:9b77eea95088, 2019-05-08 (annotated)
- Committer:
- kocemax
- Date:
- Wed May 08 13:49:01 2019 +0000
- Revision:
- 8:9b77eea95088
- Parent:
- 7:cd3cafda3dd4
- Child:
- 9:f720f5d87420
Finally, implemented power ups and fixed the angles after pad collision. Also started commenting, not much time left, so will finish the commenting and if I have more time will add a couple more 'negative' power ups.
Who changed what in which revision?
User | Revision | Line number | New 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 | 8:9b77eea95088 | 21 | /** Controls the movement physics of static game objects */ |
kocemax | 6:39bda45efeed | 22 | virtual void move(); |
kocemax | 8:9b77eea95088 | 23 | /** Draws the game objects */ |
kocemax | 6:39bda45efeed | 24 | virtual void draw(N5110 &lcd); |
kocemax | 8:9b77eea95088 | 25 | /** Gets the x and y coordinates of game objects */ |
kocemax | 8:9b77eea95088 | 26 | const Vector2D& getPos() const; |
kocemax | 8:9b77eea95088 | 27 | /** Gets the width of the game objects |
kocemax | 8:9b77eea95088 | 28 | * @return the width of the game objects |
kocemax | 8:9b77eea95088 | 29 | */ |
kocemax | 6:39bda45efeed | 30 | int getW() { return w; }; |
kocemax | 8:9b77eea95088 | 31 | /** Gets the height of the game objects |
kocemax | 8:9b77eea95088 | 32 | * @return the height of the game objects |
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 | 8:9b77eea95088 | 42 | Vector2D pos; /** x and y position of any game objects */ |
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 | 8:9b77eea95088 | 51 | /** Controls the movement physics of non-static game objects */ |
kocemax | 6:39bda45efeed | 52 | virtual void move(); |
kocemax | 8:9b77eea95088 | 53 | /** Gets the velocity of the game objects |
kocemax | 8:9b77eea95088 | 54 | * @return the velocity of the game objects |
kocemax | 8:9b77eea95088 | 55 | */ |
kocemax | 7:cd3cafda3dd4 | 56 | Vector2D& getVelocity() { return velocity; } |
kocemax | 6:39bda45efeed | 57 | |
kocemax | 6:39bda45efeed | 58 | protected: |
kocemax | 8:9b77eea95088 | 59 | Vector2D velocity; /** velocity of non-static game objects */ |
kocemax | 6:39bda45efeed | 60 | |
kocemax | 6:39bda45efeed | 61 | }; |
kocemax | 6:39bda45efeed | 62 | #endif |