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: Aim/Aim.cpp
- Revision:
- 18:c600a6545e81
- Parent:
- 13:cfdfe60a2327
- Child:
- 19:33c77517cb88
--- a/Aim/Aim.cpp Tue May 19 16:55:43 2020 +0000
+++ b/Aim/Aim.cpp Wed May 20 14:37:02 2020 +0000
@@ -28,9 +28,7 @@
{
}
-
-
-
+
void Aim::init()
{
@@ -102,6 +100,31 @@
}
}
+void Aim::acc_control(FXOS8700CQ &acc)
+{
+ float roll = acc.get_roll_angle();
+ _x = _x + roll;
+ //printf("roll = %f\n", roll);
+ float pitch = acc.get_pitch_angle();
+ _y = _y - pitch;
+ //printf("pitch = %f\n", pitch);
+
+ // check the x origin to ensure that the paddle doesn't go off screen
+ if (_x < 1) {
+ _x = 1;
+ }
+ if (_x > 84 - _width - 1) {
+ _x = 84 - _width - 1;
+ }
+ // check the y origin to ensure that the sprite doesn't go off screen
+ if (_y < 1) {
+ _y = 1;
+ }
+ if (_y > 48 - _height - 1) {
+ _y = 48 - _height - 1;
+ }
+}
+
Vector2D Aim::get_pos() {
Vector2D p = {(_x+2),(_y+2)};
return p;