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.cpp
- Revision:
- 136:04a2724f90cf
- Parent:
- 114:280903dd7e06
diff -r 888ae932cd70 -r 04a2724f90cf Paddle/Paddle.cpp
--- a/Paddle/Paddle.cpp Thu May 09 09:45:37 2019 +0000
+++ b/Paddle/Paddle.cpp Thu May 09 09:52:35 2019 +0000
@@ -25,11 +25,13 @@
}
+
void Paddle::draw(N5110 &lcd)
{
lcd.drawRect(_x,_y,_width,_height,FILL_BLACK); // draw paddle at specified coordinates
}
+
void Paddle::update(Direction d,float mag) // update the paddle's properties
{
if (_tilt == false) {
@@ -67,47 +69,56 @@
}
}
+
int Paddle::get_lives() // returns the integer _lives
{
return _lives;
}
+
void Paddle::lose_life() // decrements the member variable _lives
{
_lives--;
}
+
void Paddle::inc_life() // increment the member variable _lives
{
_lives++;
}
+
void Paddle::reset_lives()
{
_lives = 6;
}
+
Vector2D Paddle::get_pos() // returns the vector of the paddle's current position
{
Vector2D p = {_x,_y};
return p;
}
+
void Paddle::set_tilt() // sets the paddle motion option to tilt i.e. the member variable _tilt = true
{
_tilt = true;
}
+
void Paddle::set_joy() // sets the paddle motion option to joystick
{
_tilt = false;
}
+
void Paddle::recentre() // moves the paddle back to the centre of the screen (used after victory screen to restart)
{
_x = WIDTH/2 - PADDLE_WIDTH/2; // centre of the screen
}
+
void Paddle::set_sens(float sens) // sets the member variable _sens to an input
{
_sens = sens;