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.
Ball/Ball.h@23:61fa82f76808, 2019-04-18 (annotated)
- Committer:
- JamesCummins
- Date:
- Thu Apr 18 22:56:34 2019 +0000
- Revision:
- 23:61fa82f76808
- Parent:
- 17:5104ecef5bd0
- Child:
- 29:42651f87522b
Set ball speed issue fixed by creating a single ball object in top level file and referring back to that, rather than 2 different ones which don't communicate
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| JamesCummins | 9:ce0a12fb205b | 1 | #ifndef BALL_H |
| JamesCummins | 9:ce0a12fb205b | 2 | #define BALL_H |
| JamesCummins | 9:ce0a12fb205b | 3 | |
| JamesCummins | 9:ce0a12fb205b | 4 | #include "mbed.h" |
| JamesCummins | 9:ce0a12fb205b | 5 | #include "N5110.h" |
| JamesCummins | 9:ce0a12fb205b | 6 | #include "Gamepad.h" |
| JamesCummins | 9:ce0a12fb205b | 7 | #include "FXOS8700CQ.h" |
| JamesCummins | 9:ce0a12fb205b | 8 | |
| JamesCummins | 9:ce0a12fb205b | 9 | |
| JamesCummins | 9:ce0a12fb205b | 10 | class Ball { |
| JamesCummins | 9:ce0a12fb205b | 11 | |
| JamesCummins | 9:ce0a12fb205b | 12 | public: |
| JamesCummins | 9:ce0a12fb205b | 13 | //constructor method |
| JamesCummins | 9:ce0a12fb205b | 14 | Ball(); |
| JamesCummins | 9:ce0a12fb205b | 15 | //destructor method |
| JamesCummins | 9:ce0a12fb205b | 16 | ~Ball(); |
| JamesCummins | 9:ce0a12fb205b | 17 | //methods for engine |
| JamesCummins | 9:ce0a12fb205b | 18 | void init(int radius); |
| JamesCummins | 17:5104ecef5bd0 | 19 | void read_input(FXOS8700CQ &accelerometer); |
| JamesCummins | 17:5104ecef5bd0 | 20 | void update(); |
| JamesCummins | 9:ce0a12fb205b | 21 | void draw(N5110 &lcd); |
| JamesCummins | 9:ce0a12fb205b | 22 | //accessor methods |
| JamesCummins | 9:ce0a12fb205b | 23 | Vector2D get_velocity(); |
| JamesCummins | 9:ce0a12fb205b | 24 | Vector2D get_position(); |
| JamesCummins | 10:40c77d69e83c | 25 | int get_radius(); |
| JamesCummins | 9:ce0a12fb205b | 26 | //mutator methods |
| JamesCummins | 23:61fa82f76808 | 27 | void set_ball_speed(int ball_speed); //this is a constant multiplier for the ball velocity in both axes |
| JamesCummins | 23:61fa82f76808 | 28 | void set_velocity(Vector2D vel); //this is used to set the velocity at one specific instant in the code |
| JamesCummins | 9:ce0a12fb205b | 29 | void set_position(Vector2D pos); |
| JamesCummins | 10:40c77d69e83c | 30 | void set_radius(int radius); |
| JamesCummins | 9:ce0a12fb205b | 31 | |
| JamesCummins | 9:ce0a12fb205b | 32 | private: |
| JamesCummins | 11:2cf0d4ce8677 | 33 | int _radius; |
| JamesCummins | 11:2cf0d4ce8677 | 34 | int _x; |
| JamesCummins | 11:2cf0d4ce8677 | 35 | int _y; |
| JamesCummins | 9:ce0a12fb205b | 36 | Vector2D _velocity; |
| JamesCummins | 23:61fa82f76808 | 37 | int _ball_speed; |
| JamesCummins | 9:ce0a12fb205b | 38 | }; |
| JamesCummins | 9:ce0a12fb205b | 39 | #endif |