![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
One player pong with seven segment display for score keeping
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed wave_player
Fork of ECE2036Lab2StarterCode by
ball.h@0:356124c0bafc, 2014-06-17 (annotated)
- Committer:
- jlind6
- Date:
- Tue Jun 17 20:03:41 2014 +0000
- Revision:
- 0:356124c0bafc
- Child:
- 1:839d22d423bd
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jlind6 | 0:356124c0bafc | 1 | #include "tempModule.h" |
jlind6 | 0:356124c0bafc | 2 | #include "uLCD_4DGL.h" |
jlind6 | 0:356124c0bafc | 3 | |
jlind6 | 0:356124c0bafc | 4 | class Ball |
jlind6 | 0:356124c0bafc | 5 | { |
jlind6 | 0:356124c0bafc | 6 | public: |
jlind6 | 0:356124c0bafc | 7 | // Constructors |
jlind6 | 0:356124c0bafc | 8 | Ball(PinName); |
jlind6 | 0:356124c0bafc | 9 | Ball(PinName, float, float, int); |
jlind6 | 0:356124c0bafc | 10 | // Set Functions |
jlind6 | 0:356124c0bafc | 11 | void setBaseVx(float); // This sets the lowest velocity of vx (for Thermal pong) or the constant velocity |
jlind6 | 0:356124c0bafc | 12 | void setBaseVy(float); // This sets the lowest velocity of vy (for Thermal pong) or the constant velocity |
jlind6 | 0:356124c0bafc | 13 | void setVxSign(int); |
jlind6 | 0:356124c0bafc | 14 | void setVySign(int); |
jlind6 | 0:356124c0bafc | 15 | // Get Functions |
jlind6 | 0:356124c0bafc | 16 | int getFutureX(); // get estimate of where the ball will be in the next update() |
jlind6 | 0:356124c0bafc | 17 | int getFutureY(); // get estimate of where the ball will be in the next update() |
jlind6 | 0:356124c0bafc | 18 | // Member Functions |
jlind6 | 0:356124c0bafc | 19 | void reverseXDirection(); // negate the sign for when a ball hits something |
jlind6 | 0:356124c0bafc | 20 | void reverseYDirection(); // negate the sign for when a ball hits something |
jlind6 | 0:356124c0bafc | 21 | void reset(int, int, int, int, uLCD_4DGL *); // takes in a new location and new directions and draws the starting point for the ball |
jlind6 | 0:356124c0bafc | 22 | void update(uLCD_4DGL *); // moves the ball on the screen one vx and vy |
jlind6 | 0:356124c0bafc | 23 | |
jlind6 | 0:356124c0bafc | 24 | private: |
jlind6 | 0:356124c0bafc | 25 | // Data members are suggestions, feel free to add/remove |
jlind6 | 0:356124c0bafc | 26 | TempModule *tempSensor; |
jlind6 | 0:356124c0bafc | 27 | int vxSign; |
jlind6 | 0:356124c0bafc | 28 | int vySign; |
jlind6 | 0:356124c0bafc | 29 | float fx; |
jlind6 | 0:356124c0bafc | 30 | float fy; |
jlind6 | 0:356124c0bafc | 31 | int x; |
jlind6 | 0:356124c0bafc | 32 | int y; |
jlind6 | 0:356124c0bafc | 33 | int radius; |
jlind6 | 0:356124c0bafc | 34 | bool lose; |
jlind6 | 0:356124c0bafc | 35 | }; |