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@29:42651f87522b, 2019-04-27 (annotated)
- Committer:
- JamesCummins
- Date:
- Sat Apr 27 12:50:30 2019 +0000
- Revision:
- 29:42651f87522b
- Parent:
- 23:61fa82f76808
- Child:
- 37:de1f584bce71
Classic wall collision coded but always returning true (preventing classic from running) - needs debugging
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 | 29:42651f87522b | 26 | int get_ball_speed(); |
| JamesCummins | 9:ce0a12fb205b | 27 | //mutator methods |
| JamesCummins | 23:61fa82f76808 | 28 | void set_ball_speed(int ball_speed); //this is a constant multiplier for the ball velocity in both axes |
| JamesCummins | 23:61fa82f76808 | 29 | void set_velocity(Vector2D vel); //this is used to set the velocity at one specific instant in the code |
| JamesCummins | 9:ce0a12fb205b | 30 | void set_position(Vector2D pos); |
| JamesCummins | 10:40c77d69e83c | 31 | void set_radius(int radius); |
| JamesCummins | 9:ce0a12fb205b | 32 | |
| JamesCummins | 9:ce0a12fb205b | 33 | private: |
| JamesCummins | 11:2cf0d4ce8677 | 34 | int _radius; |
| JamesCummins | 11:2cf0d4ce8677 | 35 | int _x; |
| JamesCummins | 11:2cf0d4ce8677 | 36 | int _y; |
| JamesCummins | 9:ce0a12fb205b | 37 | Vector2D _velocity; |
| JamesCummins | 23:61fa82f76808 | 38 | int _ball_speed; |
| JamesCummins | 9:ce0a12fb205b | 39 | }; |
| JamesCummins | 9:ce0a12fb205b | 40 | #endif |