OCE 360 Assignment #4
Dependents: Barros_Assignment4
physics_ball.h@0:9591bae8d04c, 2017-10-31 (annotated)
- Committer:
- Kaitlyn_Barros
- Date:
- Tue Oct 31 12:59:49 2017 +0000
- Revision:
- 0:9591bae8d04c
- Child:
- 1:a2dda7baafaa
OCE 360 Assignment #4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kaitlyn_Barros | 0:9591bae8d04c | 1 | //Library for physics of LCD ball bouncing controlled by accelerometer |
Kaitlyn_Barros | 0:9591bae8d04c | 2 | //Based on MMA8452Q and 4DGL-uLCD-SE library. |
Kaitlyn_Barros | 0:9591bae8d04c | 3 | |
Kaitlyn_Barros | 0:9591bae8d04c | 4 | #include "mbed.h" |
Kaitlyn_Barros | 0:9591bae8d04c | 5 | #include "MMA8452Q.h" |
Kaitlyn_Barros | 0:9591bae8d04c | 6 | |
Kaitlyn_Barros | 0:9591bae8d04c | 7 | // Class declaration |
Kaitlyn_Barros | 0:9591bae8d04c | 8 | class physics_ball |
Kaitlyn_Barros | 0:9591bae8d04c | 9 | { |
Kaitlyn_Barros | 0:9591bae8d04c | 10 | public: |
Kaitlyn_Barros | 0:9591bae8d04c | 11 | physics_ball(); //Constructor |
Kaitlyn_Barros | 0:9591bae8d04c | 12 | float speedx; //Returns ball speed in X direction |
Kaitlyn_Barros | 0:9591bae8d04c | 13 | float speedy; //Returns ball speed in Y direction |
Kaitlyn_Barros | 0:9591bae8d04c | 14 | |
Kaitlyn_Barros | 0:9591bae8d04c | 15 | float posx; //Returns ball location in X |
Kaitlyn_Barros | 0:9591bae8d04c | 16 | float posy; //Returns ball location in Y |
Kaitlyn_Barros | 0:9591bae8d04c | 17 | |
Kaitlyn_Barros | 0:9591bae8d04c | 18 | int color; //Assigns ball color |
Kaitlyn_Barros | 0:9591bae8d04c | 19 | int radius; //Assigns ball radius |
Kaitlyn_Barros | 0:9591bae8d04c | 20 | |
Kaitlyn_Barros | 0:9591bae8d04c | 21 | int width; //Screen Spec: 128 pixel width |
Kaitlyn_Barros | 0:9591bae8d04c | 22 | int height; //Screen Spec: 128 pixel Height |
Kaitlyn_Barros | 0:9591bae8d04c | 23 | |
Kaitlyn_Barros | 0:9591bae8d04c | 24 | float time_step; |
Kaitlyn_Barros | 0:9591bae8d04c | 25 | |
Kaitlyn_Barros | 0:9591bae8d04c | 26 | void update(float time_step, int posx, int posy, int speedx, int speedy, MMA8452Q & accel); |
Kaitlyn_Barros | 0:9591bae8d04c | 27 | // Calculates new ball position given time elapsed since last position |
Kaitlyn_Barros | 0:9591bae8d04c | 28 | |
Kaitlyn_Barros | 0:9591bae8d04c | 29 | void define_space(int width, int height); |
Kaitlyn_Barros | 0:9591bae8d04c | 30 | // Defines environment, i.e the width & height of the area in which the ball can travel. |
Kaitlyn_Barros | 0:9591bae8d04c | 31 | |
Kaitlyn_Barros | 0:9591bae8d04c | 32 | |
Kaitlyn_Barros | 0:9591bae8d04c | 33 | void set_param(int radius, int color); // Defines ball parameters: radius, color (1 or 2) |
Kaitlyn_Barros | 0:9591bae8d04c | 34 | |
Kaitlyn_Barros | 0:9591bae8d04c | 35 | void set_state(int x, int y, float speedx, float speedy); //Sets new ball position & speed |
Kaitlyn_Barros | 0:9591bae8d04c | 36 | |
Kaitlyn_Barros | 0:9591bae8d04c | 37 | }; |