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.
Dependencies: mbed
Diff: rec/rect.cpp
- Revision:
- 7:1964f649676e
- Parent:
- 6:46d0caedf217
- Child:
- 9:d217a636c18d
diff -r 46d0caedf217 -r 1964f649676e rec/rect.cpp
--- a/rec/rect.cpp Tue Apr 17 20:53:43 2018 +0000
+++ b/rec/rect.cpp Tue Apr 17 23:03:03 2018 +0000
@@ -11,13 +11,13 @@
}
void rect::init(int x,int y)
{
- //rect_x = x; // x value on screen is fixed
- //rect_y = 80;
+ //set the rect move speed
rect_speed = 0.7; // default speed
}
void rect::draw(N5110 &lcd)
{
+ //draw rect om the screen
lcd.drawRect(rect_x,40,10,1,FILL_BLACK);
}
@@ -25,26 +25,15 @@
void rect::update(Direction d,float mag)
{
- rect_speed = int(mag*10.0f); // scale is arbitrary, could be changed in future
- /*if (d == N) {
+ rect_speed = int(mag*10.0f); // scale is arbitrary
- rect_y=80;
-
- } else if (d == S) {
-
- rect_y=80;
-
- }
- */
-
+ //control the movement of rect when joystick moves
+ //movement of north and south are not allowed
if (d == W) {
rect_x-=rect_speed;
} else if (d == E) {
rect_x+=rect_speed;
}
-
- // check the y origin to ensure that the paddle doesn't go off screen
-
}