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@10:e1d2289705ef, 2019-04-17 (annotated)
- Committer:
- el17m2h
- Date:
- Wed Apr 17 15:19:58 2019 +0000
- Revision:
- 10:e1d2289705ef
- Parent:
- 9:5e53bca2a4c2
- Child:
- 13:10851784af9a
Managed to fix the doodler's bounce by changing the velocity to a double instead of a int type. I also added a get_velocity_y() function to the function checking the floor's collisions.
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 | 10:e1d2289705ef | 15 | void update(Direction d, float mag, float current_vel_x, double current_vel_y); |
| el17m2h | 10:e1d2289705ef | 16 | float get_velocity_x(); |
| el17m2h | 10:e1d2289705ef | 17 | double get_velocity_y(); |
| el17m2h | 10:e1d2289705ef | 18 | float get_position_x(); |
| el17m2h | 10:e1d2289705ef | 19 | float get_position_y(); |
| el17m2h | 10:e1d2289705ef | 20 | void set_velocity(float v_x, double v_y); |
| el17m2h | 10:e1d2289705ef | 21 | void set_position(float p_x, float p_y); |
| el17m2h | 7:0d9cee90ab0d | 22 | |
| el17m2h | 4:8ec314f806ae | 23 | |
| el17m2h | 4:8ec314f806ae | 24 | private: |
| el17m2h | 4:8ec314f806ae | 25 | int _radius; |
| el17m2h | 10:e1d2289705ef | 26 | // since the velocity will be added, it will not be an integer so it cannot be a vector |
| el17m2h | 10:e1d2289705ef | 27 | float _pos_x; |
| el17m2h | 10:e1d2289705ef | 28 | float _pos_y; |
| el17m2h | 10:e1d2289705ef | 29 | // velocity needs to be float in order to decelerate |
| el17m2h | 10:e1d2289705ef | 30 | float _velocity_x; |
| el17m2h | 10:e1d2289705ef | 31 | double _velocity_y; |
| el17m2h | 10:e1d2289705ef | 32 | double _gravity; |
| el17m2h | 10:e1d2289705ef | 33 | double _up; |
| el17m2h | 4:8ec314f806ae | 34 | }; |
| el17m2h | 4:8ec314f806ae | 35 | #endif |