bouncing_ball backend

Fork of bouncing_ball by Stephen Licht

Committer:
Eric_Rupert
Date:
Thu Nov 09 14:35:57 2017 +0000
Revision:
5:17aa521aaa2f
Parent:
4:73a00b0667fc
Child:
6:68a764001a73
added top comment;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
slicht 1:0aa572c0f2b1 1 // Bouncing ball is a library adding physics based ball bouncing to the Sparkfun Experiment 3/4 rolling ball demo.
slicht 1:0aa572c0f2b1 2 // Example Code
slicht 1:0aa572c0f2b1 3 // 10/19/2017 Stephen Licht
slicht 0:aff81f4c72f3 4
Eric_Rupert 5:17aa521aaa2f 5 /*
Eric_Rupert 5:17aa521aaa2f 6 Modified by Eric Rupert, 11/7/2017-11/9/2017
Eric_Rupert 5:17aa521aaa2f 7 */
Eric_Rupert 5:17aa521aaa2f 8
slicht 0:aff81f4c72f3 9 #include "mbed.h"
slicht 0:aff81f4c72f3 10
slicht 0:aff81f4c72f3 11 #ifndef bouncing_ball_H
slicht 1:0aa572c0f2b1 12 #define bouncing_ball_H //in case any other library wishes to check for presence of this library (see example below)
slicht 1:0aa572c0f2b1 13 #include "MMA8452Q.h" //includes our new accelerometer library definitions
slicht 0:aff81f4c72f3 14
slicht 2:ba1844b0eb9f 15 #define DEFAULT_WIDTH 128
slicht 2:ba1844b0eb9f 16 #define DEFAULT_HEIGHT 128
slicht 1:0aa572c0f2b1 17 #define DEFAULT_SPEEDX 0
slicht 1:0aa572c0f2b1 18 #define DEFAULT_SPEEDY 0
slicht 1:0aa572c0f2b1 19 #define DEFAULT_POSX 64
slicht 1:0aa572c0f2b1 20 #define DEFAULT_POSY 64
slicht 1:0aa572c0f2b1 21 #define DEFAULT_COLOR 0
slicht 1:0aa572c0f2b1 22 #define DEFAULT_RADIUS 10
slicht 2:ba1844b0eb9f 23 #define GRAVITY 9.8
slicht 0:aff81f4c72f3 24
slicht 0:aff81f4c72f3 25 // Class declaration
slicht 0:aff81f4c72f3 26 class physics_ball
slicht 0:aff81f4c72f3 27 {
slicht 0:aff81f4c72f3 28 public:
slicht 2:ba1844b0eb9f 29 physics_ball();
slicht 0:aff81f4c72f3 30 ~physics_ball();
slicht 0:aff81f4c72f3 31
slicht 0:aff81f4c72f3 32 float speedx;
slicht 0:aff81f4c72f3 33 float speedy;
slicht 0:aff81f4c72f3 34 int posx;
slicht 0:aff81f4c72f3 35 int posy;
slicht 1:0aa572c0f2b1 36 int color;
slicht 1:0aa572c0f2b1 37 int radius;
slicht 1:0aa572c0f2b1 38
slicht 2:ba1844b0eb9f 39 void update(float time_step, MMA8452Q &accelerometer);
slicht 2:ba1844b0eb9f 40 void define_space(int desired_width, int desired_height);
slicht 2:ba1844b0eb9f 41 void set_param(int desired_radius, int desired_color);
slicht 2:ba1844b0eb9f 42 void set_state(int desired_x, int desired_y, float desired_vx, float desired_vy);
Eric_Rupert 4:73a00b0667fc 43 void reset_upside_down();
slicht 0:aff81f4c72f3 44
slicht 0:aff81f4c72f3 45 private:
slicht 0:aff81f4c72f3 46
slicht 2:ba1844b0eb9f 47 int _width;
slicht 2:ba1844b0eb9f 48 int _height;
slicht 2:ba1844b0eb9f 49 int _upside_down_status;
slicht 2:ba1844b0eb9f 50 float _posx_f;
slicht 2:ba1844b0eb9f 51 float _posy_f;
slicht 2:ba1844b0eb9f 52
Eric_Rupert 4:73a00b0667fc 53
slicht 0:aff81f4c72f3 54 };
slicht 0:aff81f4c72f3 55
slicht 1:0aa572c0f2b1 56 #endif //bouncing_ball_H
slicht 0:aff81f4c72f3 57
slicht 0:aff81f4c72f3 58