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.
Diff: Paddle/Paddle.h
- Revision:
- 0:92b180c8d407
diff -r 000000000000 -r 92b180c8d407 Paddle/Paddle.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Paddle/Paddle.h Tue Jan 05 01:14:11 2021 +0000
@@ -0,0 +1,90 @@
+#ifndef PADDLE_H
+#define PADDLE_H
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Gamepad.h"
+
+#define PADDLE_WIDTH 15
+#define PADDLE_HEIGHT 2
+
+/** Paddle Class
+@author James Heavey, University of Leeds
+@brief Controls the paddle in the Breakout game
+@date May 2019
+*/
+
+class Paddle
+{
+public:
+
+ /** Constructor declaration */
+ Paddle();
+
+ /** Destructor declaration */
+ ~Paddle();
+
+ /** Initialise Paddle attributes
+ * @param y @details initialises the _y value at the correct value on screen
+ * @param height @details sets the height of the paddle
+ * @param width @details sets the width of the paddle
+ */
+ void init(int y,int height,int width);
+
+ /** Draws the Paddle at at its current coordinates on the LCD
+ * @param lcd @details a N5110 pointer
+ */
+ void draw(N5110 &lcd);
+
+ /** Update the Paddle's velocity according to the Gamepad input, then update coordinates accordingly
+ * @param pad @details a Gamepad pointer
+ */
+ void update(Direction d,float mag);
+
+ /** Decrement the variable _lives */
+ void lose_life();
+
+ /** Increment the variable _lives */
+ void inc_life();
+
+ /** Set the variable _lives to 6 */
+ void reset_lives();
+
+ /** Retrieves the Paddle's lives remaining
+ * @returns the variable _lives
+ */
+ int get_lives();
+
+ /** Sets the varible _tilt to true */
+ void set_tilt();
+
+ /** Set the variable _tilt to false */
+ void set_joy();
+
+ /** Set the variable _sens
+ * @param sens @details sets _sens to local variable sens
+ */
+ void set_sens(float sens);
+
+ /** Set the _x coordinate to the middle of the screen */
+ void recentre();
+
+ /** Retrieves the Paddle's x and y velocities
+ * @returns a vector of the x and y velocities
+ */
+ Vector2D get_pos();
+
+private:
+
+ int _height;
+ int _width;
+ int _x;
+ int _y;
+ int _speed;
+ int _score;
+ int _lives;
+ float _sens;
+ bool _tilt;
+
+};
+#endif
\ No newline at end of file