PVP Wireless Pong
Dependencies: 4DGL-uLCD-SE PinDetect mbed SparkfunAnalogJoystick mbed-rtos
Fork of ECE2036Lab2StarterCode by
ball.h@7:7f2393b8ba4a, 2016-04-27 (annotated)
- Committer:
- Mpmart08
- Date:
- Wed Apr 27 15:23:54 2016 +0000
- Revision:
- 7:7f2393b8ba4a
- Parent:
- 4:7da18e3c590b
stuff
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jlind6 | 0:356124c0bafc | 1 | #include "uLCD_4DGL.h" |
jlind6 | 0:356124c0bafc | 2 | |
jlind6 | 0:356124c0bafc | 3 | class Ball |
jlind6 | 0:356124c0bafc | 4 | { |
jlind6 | 0:356124c0bafc | 5 | public: |
rishibhargava1 | 3:591086e44bf9 | 6 | Ball (uint8_t, uint8_t, uint8_t); |
jlind6 | 0:356124c0bafc | 7 | // Set Functions |
Mpmart08 | 4:7da18e3c590b | 8 | void setVx(double); // This sets the velocity |
rishibhargava1 | 3:591086e44bf9 | 9 | void setVxDir(bool); |
Mpmart08 | 4:7da18e3c590b | 10 | void setVy(double); // This sets the velocity |
rishibhargava1 | 3:591086e44bf9 | 11 | void setVyDir(bool); |
jlind6 | 0:356124c0bafc | 12 | // Get Functions |
rishibhargava1 | 3:591086e44bf9 | 13 | uint8_t getSize(); |
rishibhargava1 | 3:591086e44bf9 | 14 | uint8_t getX(); |
rishibhargava1 | 3:591086e44bf9 | 15 | uint8_t getY(); |
rishibhargava1 | 3:591086e44bf9 | 16 | uint8_t getFutureX(); // get estimate of where the ball will be in the next update() |
rishibhargava1 | 3:591086e44bf9 | 17 | uint8_t 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 |
rishibhargava1 | 3:591086e44bf9 | 21 | void reset(uint8_t, uint8_t, int, int); // takes in a new location and new directions and draws the starting point for the ball |
rishibhargava1 | 3:591086e44bf9 | 22 | void update(); // moves the ball on the screen one vx and vy |
jlind6 | 0:356124c0bafc | 23 | |
jlind6 | 0:356124c0bafc | 24 | private: |
Mpmart08 | 4:7da18e3c590b | 25 | double vx; |
rishibhargava1 | 3:591086e44bf9 | 26 | bool vxDir; //false is left (-x), true is right (+x) |
Mpmart08 | 4:7da18e3c590b | 27 | double vy; |
rishibhargava1 | 3:591086e44bf9 | 28 | bool vyDir; //false is up (-y), true is down (+y) |
Mpmart08 | 4:7da18e3c590b | 29 | double x; |
Mpmart08 | 4:7da18e3c590b | 30 | double y; |
rishibhargava1 | 3:591086e44bf9 | 31 | uint8_t diameter; |
jlind6 | 0:356124c0bafc | 32 | }; |