Fork of bouncing_ball by
bouncing_ball.h@0:aff81f4c72f3, 2017-10-19 (annotated)
- Committer:
- slicht
- Date:
- Thu Oct 19 14:07:25 2017 +0000
- Revision:
- 0:aff81f4c72f3
- Child:
- 1:0aa572c0f2b1
physics_ball class definition included in bouncing_ball.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
slicht | 0:aff81f4c72f3 | 1 | \\ Bouncing ball is a library adding physics based ball bouncing to the Sparkfun Experiment 3/4 rolling ball demo. |
slicht | 0:aff81f4c72f3 | 2 | \\ Example Code |
slicht | 0:aff81f4c72f3 | 3 | \\10/19/2017 Stephen Licht |
slicht | 0:aff81f4c72f3 | 4 | |
slicht | 0:aff81f4c72f3 | 5 | #include "mbed.h" |
slicht | 0:aff81f4c72f3 | 6 | |
slicht | 0:aff81f4c72f3 | 7 | #ifndef bouncing_ball_H |
slicht | 0:aff81f4c72f3 | 8 | #define bouncing_ball_H \\in case any other library wishes to check for presence of this library (see example below) |
slicht | 0:aff81f4c72f3 | 9 | |
slicht | 0:aff81f4c72f3 | 10 | #ifndef MMA8452Q_H |
slicht | 0:aff81f4c72f3 | 11 | #include MMA8452Q_H \\includes our new accelerometer library if not yet included |
slicht | 0:aff81f4c72f3 | 12 | #endif \\MMA8452Q_H |
slicht | 0:aff81f4c72f3 | 13 | |
slicht | 0:aff81f4c72f3 | 14 | // Class declaration |
slicht | 0:aff81f4c72f3 | 15 | class physics_ball |
slicht | 0:aff81f4c72f3 | 16 | { |
slicht | 0:aff81f4c72f3 | 17 | public: |
slicht | 0:aff81f4c72f3 | 18 | physics_ball(int color, int radius); |
slicht | 0:aff81f4c72f3 | 19 | ~physics_ball(); |
slicht | 0:aff81f4c72f3 | 20 | |
slicht | 0:aff81f4c72f3 | 21 | float speedx; |
slicht | 0:aff81f4c72f3 | 22 | float speedy; |
slicht | 0:aff81f4c72f3 | 23 | int posx; |
slicht | 0:aff81f4c72f3 | 24 | int posy; |
slicht | 0:aff81f4c72f3 | 25 | |
slicht | 0:aff81f4c72f3 | 26 | void update(float time_step, MMA8452Q accelerometer); |
slicht | 0:aff81f4c72f3 | 27 | void define_space(int width, int height); |
slicht | 0:aff81f4c72f3 | 28 | void set_param(int radius, int color); |
slicht | 0:aff81f4c72f3 | 29 | void set_state(int x, int y, float vx, float vy); |
slicht | 0:aff81f4c72f3 | 30 | |
slicht | 0:aff81f4c72f3 | 31 | private: |
slicht | 0:aff81f4c72f3 | 32 | |
slicht | 0:aff81f4c72f3 | 33 | }; |
slicht | 0:aff81f4c72f3 | 34 | |
slicht | 0:aff81f4c72f3 | 35 | #endif \\bouncing_ball_H |
slicht | 0:aff81f4c72f3 | 36 | |
slicht | 0:aff81f4c72f3 | 37 |