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.
Paddle.h
00001 #ifndef PADDLE_H 00002 #define PADDLE_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 00008 #define PADDLE_WIDTH 15 00009 #define PADDLE_HEIGHT 2 00010 00011 /** Paddle Class 00012 @author James Heavey, University of Leeds 00013 @brief Controls the paddle in the Breakout game 00014 @date May 2019 00015 */ 00016 00017 class Paddle 00018 { 00019 public: 00020 00021 /** Constructor declaration */ 00022 Paddle(); 00023 00024 /** Destructor declaration */ 00025 ~Paddle(); 00026 00027 /** Initialise Paddle attributes 00028 * @param y @details initialises the _y value at the correct value on screen 00029 * @param height @details sets the height of the paddle 00030 * @param width @details sets the width of the paddle 00031 */ 00032 void init(int y,int height,int width); 00033 00034 /** Draws the Paddle at at its current coordinates on the LCD 00035 * @param lcd @details a N5110 pointer 00036 */ 00037 void draw(N5110 &lcd); 00038 00039 /** Update the Paddle's velocity according to the Gamepad input, then update coordinates accordingly 00040 * @param pad @details a Gamepad pointer 00041 */ 00042 void update(Direction d,float mag); 00043 00044 /** Decrement the variable _lives */ 00045 void lose_life(); 00046 00047 /** Increment the variable _lives */ 00048 void inc_life(); 00049 00050 /** Set the variable _lives to 6 */ 00051 void reset_lives(); 00052 00053 /** Retrieves the Paddle's lives remaining 00054 * @returns the variable _lives 00055 */ 00056 int get_lives(); 00057 00058 /** Sets the varible _tilt to true */ 00059 void set_tilt(); 00060 00061 /** Set the variable _tilt to false */ 00062 void set_joy(); 00063 00064 /** Set the variable _sens 00065 * @param sens @details sets _sens to local variable sens 00066 */ 00067 void set_sens(float sens); 00068 00069 /** Set the _x coordinate to the middle of the screen */ 00070 void recentre(); 00071 00072 /** Retrieves the Paddle's x and y velocities 00073 * @returns a vector of the x and y velocities 00074 */ 00075 Vector2D get_pos(); 00076 00077 private: 00078 00079 int _height; 00080 int _width; 00081 int _x; 00082 int _y; 00083 int _speed; 00084 int _score; 00085 int _lives; 00086 float _sens; 00087 bool _tilt; 00088 00089 }; 00090 #endif
Generated on Wed Jul 13 2022 09:05:52 by
1.7.2