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 Joseph Lind

Files at this revision

API Documentation at this revision

Comitter:
dcleary
Date:
Thu Mar 17 20:38:26 2016 +0000
Parent:
2:6163865f5ce3
Commit message:
Pong

Changed in this revision

PinDetect.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
ball.cpp Show annotated file Show diff for this revision Revisions of this file
ball.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
paddle.cpp Show annotated file Show diff for this revision Revisions of this file
paddle.h Show annotated file Show diff for this revision Revisions of this file
tempModule.cpp Show annotated file Show diff for this revision Revisions of this file
tempModule.h Show annotated file Show diff for this revision Revisions of this file
wave_player.lib Show annotated file Show diff for this revision Revisions of this file
--- a/PinDetect.lib	Fri Jun 20 15:22:28 2014 +0000
+++ b/PinDetect.lib	Thu Mar 17 20:38:26 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
+https://developer.mbed.org/users/dcleary/code/PinDetect/#12183fe8a09d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ball.cpp	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,161 @@
+#include "mbed.h"
+#include "ball.h"
+#include "Speaker.h"
+#include "uLCD_4DGL.h"
+//#include "tempModule.h"
+
+Speaker mySpeaker(p26);//Must be PWM pin or runtime error will occur
+
+/**** Constructors ****/
+
+Ball::Ball() {
+    setXSign(-1); setYSign(0);
+    setFx(0); setFy(0);
+    setVx(1.6); setVy(1.2);
+    setX(0); setY(0);
+    setRadius(5);
+}
+
+Ball::Ball(PinName pin)
+{
+    setXSign(-1); setYSign(0);
+    setFx(0.0); setFy(0.0);
+    setVx(1.6); setVy(1.2);
+    setX(0); setY(0);
+    setRadius(5);
+    tempSensor = new TempModule(pin);
+}
+
+Ball::Ball(PinName pin, float vx, float vy)
+{
+    setXSign(-1); setYSign(0);
+    setFx(0.0); setFy(0.0);
+    setVx(vx); setVy(vy);
+    setX(0); setY(0);
+    setRadius(5);
+    tempSensor = new TempModule(pin);
+}
+
+/**** Set Functions ****/
+
+// This sets the lowest velocity, for Thermal pong, or the constant velocity of x
+void Ball::setVx(float set_vx) {vx = set_vx; }
+// This sets the lowest velocity, for Thermal pong, or the constant velocity of y
+void Ball::setVy(float set_vy) {vy = set_vy; }
+void Ball::setXSign(int set_xSign) {xSign = set_xSign; } 
+void Ball::setYSign(int set_ySign) {ySign = set_ySign; }
+void Ball::setRadius(int set_radius) {radius = set_radius; }
+void Ball::setFx(float set_fx) {fx = set_fx; }
+void Ball::setFy(float set_fy) {fy = set_fy; }
+void Ball::setX(int set_x) {x = set_x; }
+void Ball::setY(int set_y) {y = set_y; }
+void Ball::setLose(bool set_lose) {lose = set_lose; }
+
+/**** Get Functions ****/
+
+int Ball::getFutureX() {
+// calculate new X position
+    int xTemp;
+    xTemp = getFx() + ( getXSign() * getVx() );
+    return xTemp;
+}
+
+int Ball::getFutureY() {
+// calculate new Y position
+    int yTemp;
+    yTemp = getFy() + ( getYSign() * getVy() );
+    return yTemp;
+}
+
+int Ball::getRadius() {return radius;}
+int Ball::getXSign() {return xSign;}
+int Ball::getYSign() {return ySign;}
+int Ball::getX() {return x;}
+int Ball::getY() {return y;}
+float Ball::getFx() {return fx;}
+float Ball::getFy() {return fy;}
+float Ball::getVx() {return vx;}
+float Ball::getVy() {return vy;}
+bool Ball::getLose() {return lose;}
+
+/**** Member Functions ****/
+
+void Ball::reverseXDirection() {
+// negate the sign when ball hits wall or paddle
+    int xTemp;
+    xTemp = getXSign();
+    setXSign(-xTemp);
+}
+
+void Ball::reverseYDirection() {
+// negate the sign when ball hits wall or paddle
+    int yTemp;
+    yTemp = getYSign();
+    setYSign(-yTemp);
+}
+
+void Ball::startPong(int count, uLCD_4DGL *my_uLCD) {
+// initialize starting pointion for the ball
+    int rnd = 0;
+    srand(count);
+    rnd = (rand() % (118 - 2 * getRadius())) + getRadius();
+    setFx( rnd ); setX( rnd );
+    rnd = (rand() % (127 - 2 * getRadius())) + getRadius();
+    setFy( rnd ); setY( rnd );
+    rnd = rand() % 2;
+    setYSign( ((float)rnd - 0.5) * 2 );
+}
+
+void Ball::update(uLCD_4DGL *update_uLCD) {
+// moves the ball on the screen
+    update_uLCD->filled_circle(getX(), getY(), getRadius(), BLACK);
+    setFx(getFx()+(getXSign() * (1.5*getVx())));
+    setFy(getFy()+(getYSign() * (1.5*getVy())));
+    setX(getFutureX());
+    setY(getFutureY());
+    update_uLCD->filled_circle(getX(), getY(), getRadius(), WHITE);
+    
+}
+
+void Ball::resetBall() {
+// resets ball location for new game
+    setVx(1.6); setVy(1.2);
+}
+
+void Ball::testConditions( Paddle *my_paddle, uLCD_4DGL *my_uLCD ) {
+    if ((getFx()+getXSign() * getVx() <= getRadius()+3))
+    {
+        mySpeaker.PlayNote(300.0, 0.05, 0.1);
+        reverseXDirection();    
+    }
+    if ((getFy()+getYSign() * getVy() <= getRadius()+3) || (getFy()+getYSign() * getVy() >= 125-getRadius()))
+    {
+        mySpeaker.PlayNote(300.0, 0.05, 0.1);
+        reverseYDirection();
+    }
+    if (((getFx()+getXSign() * getVx() >= my_paddle->getX()) && (getFx()+getXSign() * getVx() <= my_paddle->getX()+3)) &&
+        ((getFy()+getYSign() * getVy() >= my_paddle->getY()) && (getFy()+getYSign() * getVy() <= my_paddle->getY()+my_paddle->getLength())))
+    {
+        mySpeaker.PlayNote(300.0, 0.05, 0.1);
+        reverseYDirection();
+    }
+    if ((getFx()+getXSign() * getVx() >= 123-getRadius()))
+    {
+        mySpeaker.PlayNote(300.0, 0.7, 0.3);
+        setVx(0);
+        setVy(0);
+        setLose(1);
+    }
+    if ((getFx()+getXSign() * getVx() >= my_paddle->getX()-(getRadius()+2.5)) && (getFy()+getYSign() * getVy() <= my_paddle->getY()+my_paddle->getLength())
+         && (getFy()+getYSign() * getVy() >= my_paddle->getY())) 
+    {
+        mySpeaker.PlayNote(400.0, 0.05, 0.1);
+        reverseXDirection();
+        my_paddle->setScore(1);
+        
+/*      my_uLCD->locate(1,1);
+        my_uLCD->printf("%d", my_paddle->getScore());
+*/        
+    }
+}
+
--- a/ball.h	Fri Jun 20 15:22:28 2014 +0000
+++ b/ball.h	Thu Mar 17 20:38:26 2016 +0000
@@ -1,43 +1,61 @@
 #include "tempModule.h"
 #include "uLCD_4DGL.h"
+#include "paddle.h"
 
 class Ball
 {
-public:    
+public: 
+   
     // Constructors
-    Ball ();
-    Ball (float, float, int);
-    /* For Part 3: 
-     * you need to be able to pass a pin to the 
-     * tempModule object from main, so you should
-     * add in a PinName argument.
-     */
+    
+    Ball();
     Ball(PinName);
-    Ball(PinName, float, float, int);
-    */
+    Ball(PinName,float, float);
+
     // Set Functions
-    void setBaseVx(float); // This sets the lowest velocity of vx (for Thermal pong) or the constant velocity
-    void setBaseVy(float); // This sets the lowest velocity of vy (for Thermal pong) or the constant velocity
-    void setVxSign(int); 
-    void setVySign(int);
+    void setVx(float);// This sets the lowest velocity, for Thermal pong, or the constant velocity of x
+    void setVy(float);// This sets the lowest velocity, for Thermal pong, or the constant velocity of y
+    void setXSign(int); 
+    void setYSign(int);
+    void setRadius(int);
+    void setFx(float);
+    void setFy(float);
+    void setX(int);
+    void setY(int);
+    void setLose(bool);
+
     // Get Functions
-    int getFutureX();   // get estimate of where the ball will be in the next update()
-    int getFutureY();   // get estimate of where the ball will be in the next update()
+    int getFutureX();// calculate new X position
+    int getFutureY();// calculate new Y position
+    int getXSign();
+    int getYSign();
+    int getRadius();
+    int getX();
+    int getY();
+    float getFx();
+    float getFy();
+    float getVx();
+    float getVy();
+    bool getLose();
+
     // Member Functions
-    void reverseXDirection(); // negate the sign for when a ball hits something
-    void reverseYDirection(); // negate the sign for when a ball hits something
-    void reset(int, int, int, int, uLCD_4DGL *); // takes in a new location and new directions and draws the starting point for the ball
-    void update(uLCD_4DGL *); // moves the ball on the screen one vx and vy
+    void reverseXDirection();// negate the sign when ball hits wall or paddle
+    void reverseYDirection();// negate the sign when ball hits wall or paddle
+    void startPong(int, uLCD_4DGL *);// initialize starting pointion for the ball
+    void update(uLCD_4DGL *);// moves the ball on the screen
+    void resetBall();
+    void testConditions(Paddle *,uLCD_4DGL *); 
     
 private:
-    // Data members are suggestions, feel free to add/remove
-    TempModule *tempSensor; // Pointer -- it's recommended to use "new" operator to create this
-    int vxSign;
-    int vySign;
+    TempModule *tempSensor;
+    int xSign;
+    int ySign;
     float fx;
     float fy;
+    float vx;
+    float vy;
     int x;
     int y;
     int radius;
     bool lose;
-};
+};
\ No newline at end of file
--- a/main.cpp	Fri Jun 20 15:22:28 2014 +0000
+++ b/main.cpp	Thu Mar 17 20:38:26 2016 +0000
@@ -1,22 +1,36 @@
 #include "mbed.h"
 #include "PinDetect.h"
 #include "uLCD_4DGL.h"
-#include "Speaker.h"
+#include "wave_player.h"
+#include "SDFileSystem.h"
+#include "ball.h"
+#include "paddle.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+AnalogOut DACout(p18);
+wave_player waver(&DACout);
+
+//Seven Segment Display
+DigitalOut a(p11);
+DigitalOut b(p12);
+DigitalOut c(p13);
+DigitalOut d(p14);
+DigitalOut e(p15);
+DigitalOut f(p16);
+DigitalOut g(p17);
+
+Ticker sevSegDisplay;
 
 // Pushbuttons
-PinDetect pbUp(p15); 
-PinDetect pbDown(p16);
+PinDetect pbUp(p23);//p15
+PinDetect pbDown(p24);//p16
 // uLCD
 uLCD_4DGL uLCD(p28, p27, p29);
-//Speaker
-Speaker mySpeaker(p21);
- 
-// Global variables needed for the push button interrupts
-int cornerX = 118, cornerY = 1;
-int oldCornerY = 1;
-int paddleMove = 8;
-int length = 40;
-int width = 3;
+//Ball
+Ball myBall;
+//Paddle
+Paddle myPaddle;
  
 // State machine definitions
 enum gameStateType {START, WAIT, GAME_SETUP, GAME, LOSE};
@@ -31,11 +45,51 @@
 // Global state machine variable (So that the pushbuttons can modify it)
 gameStateType gameState = START;
 
+void dScore()
+{   
+    switch(myPaddle.getScore()){
+        case 0://Zero digit
+            a=0;b=0;c=0;d=0;e=0;f =0;g=1;
+            break;        
+        case 1://One digit
+            b=0;c =0;
+            a=1;d=1;e=1;f=1;g = 1;
+            break;
+        case 2://Two digit
+            a=0;b=0;g=0;e=0;d =0;
+            f=1;c = 1;
+            break;
+        case 3://Three digit
+            e=1;f =1;
+            a=0;b=0;c=0;d=0;g = 0;
+            break;
+        case 4://Four digit
+            f=0;g=0;b=0;c =0;
+            a=1;d=1;e = 1;
+            break;
+        case 5://Five digit
+            b=1;e =1;
+            a=0;c=0;d=0;f=0;g = 0;
+            break;
+        case 6://Six digit
+            b =1;
+            a=0;c=0;d=0;e=0;f=0;g = 0;
+            break;
+        case 7://Seven digit
+            a=0;b=0;c =0;
+            d=1;e=1;f=1;g = 1;
+            break;
+        case 8://Eight digit
+            a=0;b=0;c=0;d=0;e=0;f=0;g = 0;
+            break;
+        case 9://Nine digit
+            e=0;d =0;
+            a=1;b=1;c=1;f=1;g = 1;
+            break;
+            }
+}
+
 // Pushbutton callbacks
-// WARNING: Do not call to draw anything to the uLCD in these
-// as this will cause the uLCD to crash sometimes. Update positions
-// and draw elsewhere (like it's done here).
-// Only modify the logic inside the callback functions.
 void pbUp_hit_callback (void)
 {
     switch (gameState)
@@ -44,9 +98,7 @@
         gameState = GAME_SETUP;
         break;
     case GAME:  
-        if(cornerY > paddleMove) {
-            cornerY -= paddleMove;
-        }
+        myPaddle.movePaddleUp();
         break;
     }
 }
@@ -59,9 +111,7 @@
         gameState = GAME_SETUP;
         break;
     case GAME:
-        if(cornerY < 127 - paddleMove - length){
-            cornerY += paddleMove;
-        }
+        myPaddle.movePaddleDown();
         break;
     }
 }
@@ -69,7 +119,6 @@
 int main() 
 {   
     // This is setting up the pushbuttons
-    // Don't modify this code.
     pbUp.mode(PullUp);
     pbDown.mode(PullUp);
     wait(0.1);
@@ -77,32 +126,45 @@
     pbDown.attach_deasserted(&pbDown_hit_callback);
     pbUp.setSampleFrequency();
     pbDown.setSampleFrequency();
-    // Don't modify this code.
-    
-    uLCD.display_control(PORTRAIT);
+ 
+    uLCD.display_control(PORTRAIT_R);
     uLCD.cls();
     uLCD.baudrate(BAUD_3000000);
     uLCD.background_color(BLACK);
-
-    // Initialize all your variables outside the while/switch statement
-    // to avoid compiler warning/errors
-    int vxSign = 1, vySign = 1;
-    float fx=50.0,fy=21.0,vx=1.6,vy=1.2;
-    int x=50, y=21, radius=5;
-    int score = 0;
+ 
     int i = 0;
-    int random;
- 
+    sevSegDisplay.attach(&dScore, 0.001);
+    
     while (1) 
     {   
         switch (gameState)
         {
         case START:
+            gameState = WAIT;
+            //Bouncing Ball Demo
+            float fx=50.0,fy=21.0,vx=1.3,vy=0.8;
+            int x=50,y=21,radius=4;
+            uLCD.background_color(BLACK);
             uLCD.cls();
-            uLCD.locate(0,0);
-            uLCD.printf("Pong!!!\n\n");
-            uLCD.printf("Press Key to Start");
-            gameState = WAIT;
+            //draw walls
+            uLCD.line(0, 0, 127, 0, WHITE);
+            uLCD.line(127, 0, 127, 127, WHITE);
+            uLCD.line(127, 127, 0, 127, WHITE);
+            uLCD.line(0, 127, 0, 0, WHITE);
+            while(gameState == WAIT) {//for (int i=0; i<1500; i++) {
+                //draw ball
+                uLCD.filled_circle(x, y, radius, RED);
+                //bounce off edge walls and slow down a bit?
+                if ((x<=radius+1) || (x>=126-radius)) vx = -vx;
+                if ((y<=radius+1) || (y>=126-radius)) vy = -vy;
+                //erase old ball location
+                uLCD.filled_circle(x, y, radius, BLACK);
+                //move ball
+                fx=fx+vx;
+                fy=fy+vy;
+                x=(int)fx;
+                y=(int)fy;
+            }
             break;
         case GAME_SETUP:
             uLCD.cls();
@@ -110,69 +172,23 @@
             uLCD.line(127, 0, 127, 127, 0xCFB53B);
             uLCD.line(127, 127, 0, 127, 0xCFB53B);
             uLCD.line(0, 127, 0, 0, 0xCFB53B);
-            vx = 1.6;
-            vy = 1.2;
-            srand(i);
-            random = (rand() % (118 - 2*radius)) + radius; 
-            fx = random;
-            random = (rand() % (127 - 2*radius)) + radius;
-            fy = random;
-            x=(int)fx; y=(int)fy;
-            random = rand() % 1;
-            vxSign=-1; vySign=((float)random - 0.5)*2;
-            uLCD.filled_rectangle(cornerX, cornerY, cornerX+width, cornerY+length, BLUE);
+            myBall.startPong( i, &uLCD );
+            myPaddle.initDraw( &uLCD );
             gameState = GAME;
             break;
         case GAME:
-            if ((fx+vxSign*vx<=radius+1)) 
-            {
-                vxSign = -vxSign;
-            }
-            if ((fy+vySign*vy<=radius+1) || (fy+vySign*vy>=126-radius)) 
-            {
-                vySign = -vySign;
-            }
-            if (((fx+vxSign*vx >= cornerX) && (fx+vxSign*vx <= cornerX+3)) && 
-                ((fy+vySign*vy>=cornerY) && (fy+vySign*vy<=cornerY+length))) 
-            {
-                vySign = -vySign;
-            }
-            if ((fx+vxSign*vx>=126-radius)) 
-            {
-                vx = 0;
-                vy = 0;
+            myBall.testConditions(&myPaddle, &uLCD);
+            if (myBall.getLose())
                 gameState = LOSE;
-            }
-            if ((fx+vxSign*vx>=cornerX-radius) && (fy+vySign*vy<=cornerY+length) && (fy+vySign*vy>=cornerY)) 
-            {
-                vxSign = -vxSign;
-                score++;
-                uLCD.locate(1,1);
-                uLCD.printf("%d", score);
-            }
-            uLCD.circle(x, y, radius, BLACK);
-            fx=fx+(vxSign*vx);
-            fy=fy+(vySign*vy);
-            x=(int)fx;
-            y=(int)fy;
-            uLCD.circle(x, y, radius, WHITE);
-            // We can assume that these for loops are quick enough that the paddle will move only one interval.
-            // These movements of the paddle have been optimized. Feel free to draw it out to see how it's been done.
-            if(oldCornerY > cornerY) {
-                uLCD.filled_rectangle(cornerX, oldCornerY-paddleMove+1, cornerX+width, oldCornerY, BLUE);
-                uLCD.filled_rectangle(cornerX, oldCornerY+length-paddleMove+1, cornerX+width, oldCornerY+length, BLACK);
-                oldCornerY = cornerY;
-            }
-            else if(oldCornerY < cornerY) {
-                uLCD.filled_rectangle(cornerX, oldCornerY, cornerX+width, oldCornerY+paddleMove, BLACK);
-                uLCD.filled_rectangle(cornerX, oldCornerY+length, cornerX+width, oldCornerY+length+paddleMove, BLUE);
-                oldCornerY = cornerY;
-            }
+            myBall.update( &uLCD );
+            myPaddle.redraw( &uLCD );
             break;
         case LOSE:
             uLCD.cls();
-            uLCD.printf("YOU LOSE D:");
-            score = 0;
+            //uLCD.printf("YOU LOSE D:");
+            myPaddle.resetScore();
+            myBall.setLose(0);
+            myBall.resetBall();
             wait(5.0);
             gameState = START;
             break;
@@ -181,5 +197,5 @@
             i++; 
             break;
         }
-    } 
+    }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#dfc27975e193
--- a/mbed.bld	Fri Jun 20 15:22:28 2014 +0000
+++ b/mbed.bld	Thu Mar 17 20:38:26 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paddle.cpp	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,63 @@
+#include "paddle.h"
+#include "uLCD_4DGL.h"
+
+// Constructors
+Paddle::Paddle() {
+    setLength(40);
+    setWidth(3);
+    setPaddleMove(8);
+    setX(118);//118
+    setY(1);
+    setOldY(1);
+}
+
+/**** Set Functions ****/
+
+void Paddle::setLength(int set_length) {length = set_length; }
+void Paddle::setWidth(int set_width) {width = set_width; }
+void Paddle::setPaddleMove(int set_pMove){paddleMove = set_pMove; }
+void Paddle::setScore(int set_score) {score += set_score; }
+void Paddle::setX(int set_x) {x = set_x; }
+void Paddle::setY(int set_y) {y = set_y; }
+void Paddle::setOldY(int set_oy) {oldy = set_oy; }
+
+/**** Get Functions ****/
+
+int Paddle::getLength() {return length; }
+int Paddle::getWidth() {return width; }
+int Paddle::getPaddleMove() {return paddleMove; }
+int Paddle::getScore() {return score; }
+int Paddle::getX() {return x; }
+int Paddle::getY() {return y; }
+int Paddle::getOldY() {return oldy; }
+
+/**** Member Functions ****/
+
+void Paddle::movePaddleUp() { 
+// moves the paddle up (does not draw!)
+    if(y > paddleMove)
+        y -= paddleMove;
+}
+void Paddle::movePaddleDown() { 
+// moves the paddle up (does not draw!)
+    if(y < 127 - paddleMove - length)
+        y += paddleMove;
+}
+void Paddle::resetScore() {score = 0; } // resets score
+void Paddle::initDraw(uLCD_4DGL *uLCD) {
+// draw the paddle initially (draws the whole thing)
+    uLCD->filled_rectangle(x, y, x + width, y + length, BLUE);
+}
+void Paddle::redraw(uLCD_4DGL *uLCD) {
+// draws the paddle for a move (does NOT draw the whole thing)
+    if(oldy > y) {
+        uLCD->filled_rectangle(x, oldy - paddleMove + 1, x + width, oldy, BLUE);
+        uLCD->filled_rectangle(x, oldy + length - paddleMove + 1, x + width, oldy + length, BLACK);
+        oldy = y;
+    }
+    else if(oldy < y) {
+        uLCD->filled_rectangle(x, oldy, x + width, oldy + paddleMove, BLACK);
+        uLCD->filled_rectangle(x, oldy + length, x + width, oldy + length + paddleMove, BLUE);
+        oldy = y;
+    }
+}// end redraw
\ No newline at end of file
--- a/paddle.h	Fri Jun 20 15:22:28 2014 +0000
+++ b/paddle.h	Thu Mar 17 20:38:26 2016 +0000
@@ -1,29 +1,40 @@
 #include "uLCD_4DGL.h"
+#ifndef PADDLE_H
+#define PADDLE_H
 
 class Paddle 
 {
 public:
     // Constructors
-    Paddle(int, int);
-    Paddle(int, int, int, int);
+    Paddle();
+    
     // Set Functions
     void setLength(int);
     void setWidth(int);
-    void setPaddleMove(int);  
-    void setLimits(int, int); // upper and lower limits of the paddle
+    void setPaddleMove(int);
+    void setScore(int);
+    void setX(int);
+    void setY(int);
+    void setOldY(int);
+    
     // Get Function
+    int getLength();
+    int getWidth();
+    int getPaddleMove();
     int getScore();
+    int getX();
+    int getY();
+    int getOldY();
+    
     // Member Functions
-    void movePaddle(bool); // moves the paddle locations (does not draw!)
-    bool checkHitX(int, int, int); // Using a position and radius, checks to see if something has hit the paddle in the x direction
-    bool checkHitY(int, int, int); // Using a position and radius, checks to see if something has hit the paddle in the y direction
+    void movePaddleUp();
+    void movePaddleDown();
     void resetScore(); // sets score to 0
     void initDraw(uLCD_4DGL *uLCD); // draw the paddle initially (draws the whole thing)
     void redraw(uLCD_4DGL *uLCD); // draws the paddle for a move (does NOT draw the whole thing)
     
 
 private:
-    // Data members are suggestions, feel free to add/remove
     int score;
     int x;
     int y;
@@ -31,7 +42,6 @@
     int length;
     int width;
     int paddleMove;
-    int topLimit;
-    int bottomLimit;
 };
 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tempModule.cpp	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+#include "tempModule.h"
+
+TempModule::TempModule(PinName pin) : _sensor(pin)
+{
+    setBaseVx(1.6); setBaseVy(1.2);
+}
+
+TempModule::TempModule(PinName pin, float vx, float vy) : _sensor(pin)
+{
+    setBaseVx(vx); setBaseVy(vy);
+}
+
+void TempModule::setBaseVx(float vx) {basevx = vx;}
+void TempModule::setBaseVy(float vy) {basevy = vy;}
+float TempModule::getVx() {
+    float _vx = 0.0; float anaTemp = read();
+    _vx = basevx * anaTemp + 2.3;
+    return _vx;
+}
+
+float TempModule::getVy() {
+    float _vy = 0.0; float anaTemp = read();
+    _vy = basevy * anaTemp + 1.6;
+    return _vy; 
+}
+
+float TempModule::getVx(uLCD_4DGL *temp_uLCD) {
+    float _vx = 0.0; float anaTemp = read(); float temperature = 0;
+    _vx = basevx * anaTemp;
+    temperature = ((anaTemp*3.3)-0.500)*100.0;
+    temp_uLCD->locate(0,15);
+    temp_uLCD->printf("%f", temperature);
+    return _vx;
+}
+
+float TempModule::read() {
+    return _sensor.read();
+}
\ No newline at end of file
--- a/tempModule.h	Fri Jun 20 15:22:28 2014 +0000
+++ b/tempModule.h	Thu Mar 17 20:38:26 2016 +0000
@@ -1,16 +1,8 @@
+#ifndef TEMPMODULE_H
+#define TEMPMODULE_H
+#include "mbed.h"
 #include "uLCD_4DGL.h"
 
-/* Recommendation:
- * This class doesn't need to be declared outside the Ball class,
- * so you can create it inside the Ball class and use it only
- * in the Ball class.
- *
- * If the main function or multiple objects use a piece of hardware
- * or a class object (like uLCD or mySpeaker), you should pass a 
- * pointer into the object rather than creating the object (either
- * in the stack or using new).
- */
-
 class TempModule 
 {
 public:
@@ -37,15 +29,4 @@
     float basevy;
     int counter;
 };
-
-TempModule::TempModule (PinName pin) : _sensor(pin)
-{
-    // Constructor code goes here
-    // you can ignore initializing _sensor, we've already done that
-}
-
-TempModule::TempModule (PinName pin, float vx, float vy) : _sensor(pin)
-{
-    // Constructor code goes here
-    // you can ignore initializing _sensor, we've already done that
-}
\ No newline at end of file
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wave_player.lib	Thu Mar 17 20:38:26 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/sravet/code/wave_player/#acc3e18e77ad