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@3:c93d1b51785c, 2016-03-17 (annotated)
- Committer:
- dcleary
- Date:
- Thu Mar 17 20:38:26 2016 +0000
- Revision:
- 3:c93d1b51785c
- Parent:
- 1:839d22d423bd
Pong
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" |
dcleary | 3:c93d1b51785c | 3 | #include "paddle.h" |
jlind6 | 0:356124c0bafc | 4 | |
jlind6 | 0:356124c0bafc | 5 | class Ball |
jlind6 | 0:356124c0bafc | 6 | { |
dcleary | 3:c93d1b51785c | 7 | public: |
dcleary | 3:c93d1b51785c | 8 | |
jlind6 | 0:356124c0bafc | 9 | // Constructors |
dcleary | 3:c93d1b51785c | 10 | |
dcleary | 3:c93d1b51785c | 11 | Ball(); |
jlind6 | 0:356124c0bafc | 12 | Ball(PinName); |
dcleary | 3:c93d1b51785c | 13 | Ball(PinName,float, float); |
dcleary | 3:c93d1b51785c | 14 | |
jlind6 | 0:356124c0bafc | 15 | // Set Functions |
dcleary | 3:c93d1b51785c | 16 | void setVx(float);// This sets the lowest velocity, for Thermal pong, or the constant velocity of x |
dcleary | 3:c93d1b51785c | 17 | void setVy(float);// This sets the lowest velocity, for Thermal pong, or the constant velocity of y |
dcleary | 3:c93d1b51785c | 18 | void setXSign(int); |
dcleary | 3:c93d1b51785c | 19 | void setYSign(int); |
dcleary | 3:c93d1b51785c | 20 | void setRadius(int); |
dcleary | 3:c93d1b51785c | 21 | void setFx(float); |
dcleary | 3:c93d1b51785c | 22 | void setFy(float); |
dcleary | 3:c93d1b51785c | 23 | void setX(int); |
dcleary | 3:c93d1b51785c | 24 | void setY(int); |
dcleary | 3:c93d1b51785c | 25 | void setLose(bool); |
dcleary | 3:c93d1b51785c | 26 | |
jlind6 | 0:356124c0bafc | 27 | // Get Functions |
dcleary | 3:c93d1b51785c | 28 | int getFutureX();// calculate new X position |
dcleary | 3:c93d1b51785c | 29 | int getFutureY();// calculate new Y position |
dcleary | 3:c93d1b51785c | 30 | int getXSign(); |
dcleary | 3:c93d1b51785c | 31 | int getYSign(); |
dcleary | 3:c93d1b51785c | 32 | int getRadius(); |
dcleary | 3:c93d1b51785c | 33 | int getX(); |
dcleary | 3:c93d1b51785c | 34 | int getY(); |
dcleary | 3:c93d1b51785c | 35 | float getFx(); |
dcleary | 3:c93d1b51785c | 36 | float getFy(); |
dcleary | 3:c93d1b51785c | 37 | float getVx(); |
dcleary | 3:c93d1b51785c | 38 | float getVy(); |
dcleary | 3:c93d1b51785c | 39 | bool getLose(); |
dcleary | 3:c93d1b51785c | 40 | |
jlind6 | 0:356124c0bafc | 41 | // Member Functions |
dcleary | 3:c93d1b51785c | 42 | void reverseXDirection();// negate the sign when ball hits wall or paddle |
dcleary | 3:c93d1b51785c | 43 | void reverseYDirection();// negate the sign when ball hits wall or paddle |
dcleary | 3:c93d1b51785c | 44 | void startPong(int, uLCD_4DGL *);// initialize starting pointion for the ball |
dcleary | 3:c93d1b51785c | 45 | void update(uLCD_4DGL *);// moves the ball on the screen |
dcleary | 3:c93d1b51785c | 46 | void resetBall(); |
dcleary | 3:c93d1b51785c | 47 | void testConditions(Paddle *,uLCD_4DGL *); |
jlind6 | 0:356124c0bafc | 48 | |
jlind6 | 0:356124c0bafc | 49 | private: |
dcleary | 3:c93d1b51785c | 50 | TempModule *tempSensor; |
dcleary | 3:c93d1b51785c | 51 | int xSign; |
dcleary | 3:c93d1b51785c | 52 | int ySign; |
jlind6 | 0:356124c0bafc | 53 | float fx; |
jlind6 | 0:356124c0bafc | 54 | float fy; |
dcleary | 3:c93d1b51785c | 55 | float vx; |
dcleary | 3:c93d1b51785c | 56 | float vy; |
jlind6 | 0:356124c0bafc | 57 | int x; |
jlind6 | 0:356124c0bafc | 58 | int y; |
jlind6 | 0:356124c0bafc | 59 | int radius; |
jlind6 | 0:356124c0bafc | 60 | bool lose; |
dcleary | 3:c93d1b51785c | 61 | }; |