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
Engine/Engine.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 | 2:360a6c301a4e | 1 | #ifndef ENGINE_H |
el17m2h | 2:360a6c301a4e | 2 | #define ENGINE_H |
el17m2h | 2:360a6c301a4e | 3 | |
el17m2h | 2:360a6c301a4e | 4 | #include "mbed.h" |
el17m2h | 2:360a6c301a4e | 5 | #include "N5110.h" |
el17m2h | 2:360a6c301a4e | 6 | #include "Gamepad.h" |
el17m2h | 2:360a6c301a4e | 7 | #include "Floors.h" |
el17m2h | 4:8ec314f806ae | 8 | #include "Doodler.h" |
el17m2h | 2:360a6c301a4e | 9 | |
el17m2h | 2:360a6c301a4e | 10 | class Engine{ |
el17m2h | 2:360a6c301a4e | 11 | public: |
el17m2h | 2:360a6c301a4e | 12 | Engine(); |
el17m2h | 2:360a6c301a4e | 13 | ~Engine(); |
el17m2h | 4:8ec314f806ae | 14 | void init(int floors_width, int floors_height, int doodler_radius); |
el17m2h | 5:8814d6de77d0 | 15 | void read_input(Gamepad &pad); |
el17m2h | 5:8814d6de77d0 | 16 | void update(Gamepad &pad); |
el17m2h | 2:360a6c301a4e | 17 | void draw(N5110 &lcd); |
el17m2h | 6:848d1e4c1a31 | 18 | void check_floors_collision(Gamepad &pad); |
el17m2h | 9:5e53bca2a4c2 | 19 | void shift_floors(Gamepad &pad); |
el17m2h | 4:8ec314f806ae | 20 | |
el17m2h | 7:0d9cee90ab0d | 21 | private: |
el17m2h | 9:5e53bca2a4c2 | 22 | Floors _f; // cambiar a _f[5] (array de pisos) |
el17m2h | 4:8ec314f806ae | 23 | |
el17m2h | 2:360a6c301a4e | 24 | int _floors_height; |
el17m2h | 2:360a6c301a4e | 25 | int _floors_width; |
el17m2h | 4:8ec314f806ae | 26 | |
el17m2h | 2:360a6c301a4e | 27 | // x and y positions of the floors |
el17m2h | 9:5e53bca2a4c2 | 28 | Vector2D _floors_vel; |
el17m2h | 9:5e53bca2a4c2 | 29 | Vector2D _f_pos; |
el17m2h | 5:8814d6de77d0 | 30 | |
el17m2h | 5:8814d6de77d0 | 31 | Doodler _dood; |
el17m2h | 8:90e789413e0b | 32 | int _doodler_radius; |
el17m2h | 8:90e789413e0b | 33 | Vector2D _doodler_pos; |
el17m2h | 8:90e789413e0b | 34 | Vector2D _doodler_vel; |
el17m2h | 5:8814d6de77d0 | 35 | |
el17m2h | 5:8814d6de77d0 | 36 | Direction _d; |
el17m2h | 5:8814d6de77d0 | 37 | float _mag; |
el17m2h | 7:0d9cee90ab0d | 38 | |
el17m2h | 2:360a6c301a4e | 39 | }; |
el17m2h | 2:360a6c301a4e | 40 | #endif |