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
Doodler/Doodler.h@9:5e53bca2a4c2, 2019-04-16 (annotated)
- Committer:
- el17m2h
- Date:
- Tue Apr 16 19:51:12 2019 +0000
- Revision:
- 9:5e53bca2a4c2
- Parent:
- 8:90e789413e0b
- Child:
- 10:e1d2289705ef
Changed the values of the positions and velocities to vectors so that they are easier to manipulate. I made use of the float absolute function (fabs) function to make the ball decelerate to a zero velocity while going upwards.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17m2h | 4:8ec314f806ae | 1 | #ifndef DOODLER_H |
| el17m2h | 4:8ec314f806ae | 2 | #define DOODLER_H |
| el17m2h | 4:8ec314f806ae | 3 | |
| el17m2h | 4:8ec314f806ae | 4 | #include "mbed.h" |
| el17m2h | 4:8ec314f806ae | 5 | #include "N5110.h" |
| el17m2h | 4:8ec314f806ae | 6 | #include "Gamepad.h" |
| el17m2h | 4:8ec314f806ae | 7 | #include "Floors.h" |
| el17m2h | 5:8814d6de77d0 | 8 | |
| el17m2h | 4:8ec314f806ae | 9 | class Doodler{ |
| el17m2h | 4:8ec314f806ae | 10 | public: |
| el17m2h | 4:8ec314f806ae | 11 | Doodler(); |
| el17m2h | 4:8ec314f806ae | 12 | ~Doodler(); |
| el17m2h | 5:8814d6de77d0 | 13 | void init(int radius); |
| el17m2h | 8:90e789413e0b | 14 | void draw(N5110 &lcd); |
| el17m2h | 9:5e53bca2a4c2 | 15 | void update(Direction d, float mag, Vector2D current_vel); |
| el17m2h | 8:90e789413e0b | 16 | Vector2D get_velocity(); |
| el17m2h | 7:0d9cee90ab0d | 17 | Vector2D get_position(); |
| el17m2h | 7:0d9cee90ab0d | 18 | void set_velocity(Vector2D v); |
| el17m2h | 7:0d9cee90ab0d | 19 | void set_position(Vector2D p); |
| el17m2h | 7:0d9cee90ab0d | 20 | |
| el17m2h | 4:8ec314f806ae | 21 | |
| el17m2h | 4:8ec314f806ae | 22 | private: |
| el17m2h | 4:8ec314f806ae | 23 | int _radius; |
| el17m2h | 9:5e53bca2a4c2 | 24 | Vector2D _pos; |
| el17m2h | 7:0d9cee90ab0d | 25 | Vector2D _velocity; |
| el17m2h | 8:90e789413e0b | 26 | Vector2D _current_vel; |
| el17m2h | 7:0d9cee90ab0d | 27 | float _gravity; |
| el17m2h | 7:0d9cee90ab0d | 28 | float _up; |
| el17m2h | 4:8ec314f806ae | 29 | }; |
| el17m2h | 4:8ec314f806ae | 30 | #endif |