Retro game that let's the player steer a ball through a hole filled maze. Has multiple levels of increasing difficulty.

Dependencies:   LCD_ST7735 MusicEngine RETRO_BallsAndThings mbed

Ball and Holes

In this game I attempted to create somewhat natural movement of the ball by implementing gravity and friction which combined over time determine the speed of the ball. Playing with the settings (aka. the magic numbers) that are spread out all over game.cpp, gives different effects, such as an icy, rough or liquid-like surface.

It took some time to figure out how to post my very first youtube video. Sorry for the shaky recording. Trying to record the video with my phone while playing the game in one hand was quite challenging, but here it is;

The left and right buttons are used to cheat: restart the current or go to the next level. Up and down control the game-tick. During game-play the robot-button shows the accelerator graph and the ship-button mutes the sound.

BTW. If your ball happens to get stuck, tilting the console in the opposite direction will set it free. For sake of argument: these magnetic wall-ends are in the words of Bob Ross "a happy accident". Since there is no specific code for it, others might call it a bug. As it results in more interesting game-play, I didn't attempt to fix it, but left a comment for those who dare to look at the mess I call code.

Files at this revision

API Documentation at this revision

Comitter:
maxint
Date:
Sat Feb 28 11:40:39 2015 +0000
Parent:
5:67e75a4f0b52
Child:
7:6e7b789f4060
Commit message:
Added walls to maze

Changed in this revision

Accelerometer.cpp Show diff for this revision Revisions of this file
Accelerometer.h Show diff for this revision Revisions of this file
Ball.cpp Show diff for this revision Revisions of this file
Ball.h Show diff for this revision Revisions of this file
Game.cpp Show annotated file Show diff for this revision Revisions of this file
Game.h Show annotated file Show diff for this revision Revisions of this file
MusicEngine.lib Show annotated file Show diff for this revision Revisions of this file
Paddle.cpp Show diff for this revision Revisions of this file
Paddle.h Show diff for this revision Revisions of this file
Physics.cpp Show diff for this revision Revisions of this file
Physics.h Show diff for this revision Revisions of this file
RETRO_BallsAndThings.lib Show annotated file Show diff for this revision Revisions of this file
Shapes.cpp Show diff for this revision Revisions of this file
Shapes.h Show diff for this revision Revisions of this file
SoundFX.h Show diff for this revision Revisions of this file
SoundFx.cpp Show diff for this revision Revisions of this file
Vector.cpp Show diff for this revision Revisions of this file
Vector.h Show diff for this revision Revisions of this file
--- a/Accelerometer.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-#include "Accelerometer.h"
-
-Accelerometer::Accelerometer(int nI2cAddress, LCD_ST7735* pDisp) : i2cAddress(nI2cAddress), i2c(P0_5, P0_4)
-{   // constructor
-    this->i2c.frequency(400000);        // fast I2C is 400 KHz, not 400 Hz. Default frequency is 100 KHz
-    this->writeRegister(0x2A, 0x01); // initialize accelerometer (set CTRL_REG1 bit ACTIVE)
-    this->pDisp=pDisp;
-
-    this->colors[0] = Color565::Red;
-    this->colors[1] = Color565::Green;
-    this->colors[2] = Color565::Blue;
-}
-
-void Accelerometer::readRegisters(char address, char* buffer, int len) {
-//    int nStart=this->tWait.read_ms();
-    this->i2c.write(i2cAddress, &address, 1, true);
-    this->i2c.read(i2cAddress | 1, buffer, len);
-//    printDouble((double)this->tWait.read_ms()-nStart, 10, 10);
-}
-
-int Accelerometer::writeRegister(char address, char value) {    
-    char buffer[2] = { address, value };
-    
-    return this->i2c.write(i2cAddress, buffer, 2);
-}
-
-double Accelerometer::convert(char* buffer) {
-    double val = ((buffer[0] << 2) | (buffer[1] >> 6));
-            
-    if (val > 511.0) 
-        val -= 1024.0;
-    
-    return val / 512.0;
-}
-
-void Accelerometer::getXYZ(double& x, double& y, double& z) {
-    char buffer[6];
-    
-    this->readRegisters(0x01, buffer, 6);
-    
-    x = this->convert(buffer);
-    y = this->convert(buffer + 2);
-    z = this->convert(buffer + 4);
-}
-
-//
-// Accellerator graph for debug purposes
-//
-
-void Accelerometer::drawAxes()
-{
-    for (int i = 0; i < 3; i++) {
-        this->pDisp->fillRect(0, i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING), this->pDisp->getWidth(), i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING) + Accelerometer::GRAPH_HEIGHT, Color565::fromRGB(i==0?0x22:0, i==1?0x22:0, i==2?0x22:0));
-        this->pDisp->drawLine(0, i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING), 0, i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING) + Accelerometer::GRAPH_HEIGHT, Color565::White);
-        this->pDisp->drawLine(0, i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING) + Accelerometer::GRAPH_HEIGHT / 2, this->pDisp->getWidth(), i * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING) + Accelerometer::GRAPH_HEIGHT / 2, Color565::White);
-    }
-}
-
-void Accelerometer::drawPoint(int axis, double value)
-{
-    if (value < -1.0)
-        value = -1.0;
-
-    if (value > 1.0)
-        value = 1.0;
-
-    value += 1.0;
-    value /= 2.0;
-    value = 1.0 - value;
-    value *= Accelerometer::GRAPH_HEIGHT;
-
-    this->pDisp->setPixel(this->graphX, axis * (Accelerometer::GRAPH_HEIGHT + Accelerometer::GRAPH_SPACING) + (int)value, this->colors[axis]);
-}
-
-void Accelerometer::resetGraph()
-{
-    this->graphX = 0;
-    this->pDisp->clearScreen();
-    //this->pDisp->fillRect(0, 0, this->pDisp->getWidth(), this->pDisp->getHeight(), Color565::fromRGB(0x11, 0x33, 0x22));
-    this->drawAxes();
-}
-
-void Accelerometer::checkGraphReset()
-{
-    if (this->graphX > this->pDisp->getWidth())
-    {
-        this->resetGraph();
-    }
-}
-
-void Accelerometer::updateGraph()
-{
-    double x, y, z;
-    this->getXYZ(x, y, z);
-    
-    this->checkGraphReset();
-    this->drawPoint(0, x);
-    this->drawPoint(1, y);
-    this->drawPoint(2, z);
-    this->graphX++;
-}
-
--- a/Accelerometer.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#pragma once
-#include "mbed.h"
-
-#include "Color565.h"
-#include "LCD_ST7735.h"
-
-class Accelerometer
-{
-    public:
-        Accelerometer(int nI2cAddress, LCD_ST7735* pDisp);
-        void getXYZ(double& x, double& y, double& z);
-        void resetGraph();
-        void updateGraph();
-
-    private:
-        static const int GRAPH_HEIGHT = 40;
-        static const int GRAPH_SPACING = 2;
-
-        void readRegisters(char address, char* buffer, int len);
-        int writeRegister(char address, char value);
-        double convert(char* buffer);
-
-        int i2cAddress;
-        I2C i2c;
-        LCD_ST7735* pDisp;
-        unsigned short colors[3];
-        int graphX;    
-
-        void drawAxes();
-        void drawPoint(int axis, double value);
-        void checkGraphReset();
-};
\ No newline at end of file
--- a/Ball.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-#include "Ball.h"
-
-Ball::Ball() : vSpeed()
-{   // constructor
-}
-
-Ball::Ball(LCD_ST7735* pDisp) : vSpeed()
-{   // constructor
-    this->pDisp=pDisp;
-    this->fActive=false;
-}
-
-uint16_t Ball::dimmedColor(uint16_t uColor)
-{
-    uint16_t r, g, b;
-   
-    r=(uColor >> 11) <<3;
-    g=((uColor >> 5) & 0x3F) <<2;
-    b=(uColor & 0x1F) << 3;
-    r=r*2/3;
-    g=g*2/3;
-    b=b*2/3;
-//    r=r/2;
-//    g=g/2;
-//    b=b/2;
-
-    return(Color565::fromRGB((uint16_t)r,(uint16_t)g,(uint16_t)b));
-}
-
-void Ball::initialize(int nX, int nY, int nR, uint16_t uColor)
-{
-    this->pos.set(nX, nY);
-    this->nRadius=nR;
-    this->uColor=uColor;
-    this->uColorHigh=uColor;
-    this->uColorMid=dimmedColor(uColorHigh);
-    this->uColorLow=dimmedColor(uColorMid);
-
-}
-
-void Ball::setSpeed(int X, int Y)
-{
-    this->vSpeed.set(X, Y);
-}
-
-void Ball::changeSpeed(bool fUp)
-{
-    if(fUp)
-    {
-        if(this->vSpeed.getSize()<=4.0) this->vSpeed.add(1.0);
-    }
-    else
-    {
-        if(this->vSpeed.getSize()>=1.0)
-            this->vSpeed.add(-1.0);
-        else        // TODO: added code below to allow zero speed pause of ball
-            this->vSpeed.set(0,0);
-    }
-}
-
-void Ball::unmove()
-{   // move back to previous position
-    pos.set(pos.getPrev());
-}
-
-void Ball::update()
-{
-    this->pos.move(this->vSpeed);
-}
-
-Circle Ball::getBoundingCircle()
-{
-    return(Circle(this->pos.getX(), this->pos.getY(), this->nRadius));
-}
-
-bool Ball::collides(Rectangle r)
-{
-    Circle cBall=this->getBoundingCircle();
-    Rectangle rBall=cBall.getBoundingRectangle();
-
-/*    
-char szBuffer[256];
-sprintf(szBuffer, "c:%d,%d      ", cBall.getX(), cBall.getY());
-this->pDisp->drawString(font_oem, 0, 0, szBuffer);
-*/
-    return(rBall.collides(r));
-}
-
-void Ball::Bounce(Vector vBounce)
-{   // change the direction in a certain direction
-    this->unmove(); // undo move to pre-bouncing position to avoid drawing on colliding position
-
-    this->vSpeed.multiply(vBounce);
-
-    // check speed w/max
-    if(this->vSpeed.y>5.0) this->vSpeed.y=5;
-}
-
-
-
-void Ball::clear()
-{
-    Point p=pos.getCur();
-    this->pDisp->fillCircle(p.getX(),p.getY(), this->nRadius, Color565::Black, Color565::Black);
-}
-
-void Ball::clearPrev()
-{
-    Point p=pos.getPrev();
-    this->pDisp->fillCircle(p.getX(),p.getY(), this->nRadius, Color565::Black, Color565::Black);
-}
-
-
-void Ball::draw()
-{   // render the object on the screen, based on its current position
-    Point p=pos.getCur();
-    if(this->nRadius>3)
-    {
-        this->pDisp->fillCircle(p.getX(), p.getY(), this->nRadius, this->uColorLow, this->uColorLow);
-        this->pDisp->fillCircle(p.getX()-this->nRadius/3, p.getY()-this->nRadius/3, this->nRadius/2, this->uColorMid, this->uColorMid);
-        this->pDisp->setPixel(p.getX()-this->nRadius/2, p.getY()-this->nRadius/2, this->uColorHigh);
-    }
-    else
-        this->pDisp->fillCircle(p.getX(), p.getY(), this->nRadius, this->uColorMid, this->uColorMid);
-}
-
-void Ball::redraw()
-{   // redraw the ball if its position has changed
-    if(pos.hasChanged())
-    {
-        clearPrev();
-        draw();
-    }
-}
\ No newline at end of file
--- a/Ball.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#pragma once
-#include "mbed.h"
-
-#include "Color565.h"
-#include "font_OEM.h"
-#include "LCD_ST7735.h"
-
-#include "Shapes.h"
-#include "Vector.h"
-#include "Physics.h"
-
-class Ball
-{
-    public:
-        static const bool fFixed=false;
-        bool fActive;
-
-        Ball();
-        Ball(LCD_ST7735* pDisp);
-        void initialize(int X, int Y, int R, uint16_t uColor);
-        void setSpeed(int X, int Y);
-        void changeSpeed(bool fUp);
-        void unmove();
-        void update();
-        void clear();
-        void clearPrev();
-        void draw();
-        void redraw();
-        
-        Position pos;
-        int nRadius;
-        Vector vSpeed;
-
-        Circle getBoundingCircle();
-        bool collides(Rectangle r);
-        void Bounce(Vector vBounce);
-
-    private:
-        uint16_t uColor;
-        uint16_t uColorHigh;
-        uint16_t uColorMid;
-        uint16_t uColorLow;
-        LCD_ST7735* pDisp;
-
-        uint16_t dimmedColor(uint16_t uColor);
-};
-
--- a/Game.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ b/Game.cpp	Sat Feb 28 11:40:39 2015 +0000
@@ -2,7 +2,7 @@
 
 const char* Game::LOSE_1 = "Game over.";
 const char* Game::LOSE_2 = "Press ship to restart.";
-const char* Game::SPLASH_1 = "-*- Balls and paddle -*-";
+const char* Game::SPLASH_1 = "-*- Ball and holes -*-";
 const char* Game::SPLASH_2 = "Press ship to start.";
 const char* Game::SPLASH_3 = "Made by Maxint";
 
@@ -21,7 +21,7 @@
 
 
 Game::Game() : left(P0_14, PullUp), right(P0_11, PullUp), down(P0_12, PullUp), up(P0_13, PullUp), square(P0_16, PullUp), circle(P0_1, PullUp), led1(P0_9), led2(P0_8), 
-    ain(P0_15), i2c(P0_5, P0_4), disp(P0_19, P0_20, P0_7, P0_21, P0_22, P1_15, P0_2, LCD_ST7735::RGB), accel(this->I2C_ADDR, &disp), vGravity(0, 0.1), ball(&disp), paddle(&disp)
+    ain(P0_15), disp(P0_19, P0_20, P0_7, P0_21, P0_22, P1_15, P0_2, LCD_ST7735::RGB), accel(this->I2C_ADDR, &disp), vGravity(0, 0.1), vFriction(-0.02, -0.02), ball(&disp)
 {
     this->disp.setOrientation(LCD_ST7735::Rotate270, false);
     this->disp.setForegroundColor(WHITE);
@@ -33,12 +33,12 @@
     this->lastUp = false;
     this->lastDown = false;
     this->mode = true;          // mode: true=game, false=graph
-
+    
     this->nGameTickDelay=25;    // game tickdelay can be adjusted using up/down
 
-    //this->aBalls[2]={ Ball(&disp),  Ball(&disp) };
-    for(int i=0; i<NUM_BALLS; i++)
-        this->aBalls[i]=Ball(&(this->disp));
+    nTopWall=8;
+    for(int i=0; i<NUM_WALLS; i++)
+        aWalls[i]=Wall(&(this->disp));
 
     this->snd.reset();
 }
@@ -58,110 +58,139 @@
     this->snd.reset();
     this->nBalls = 4;
     this->nScore = 0;
-    this->nTopWall = 8;
-    this->fDrawTopWall=true;
     
 //    this->tWait.start();      // start the timer
 
-    this->initializePaddle();
-    this->setNoBalls();     // reset all balls
+    //char sWalls[]="W010010A0";
+    for(int i=0; i<NUM_WALLS; i++)
+    {
+        aWalls[i]=Wall(&(this->disp));
+        //aWalls[i].fActive=false;
+    }
+
+    // hor
+    addWall("01:1");    // top edge
+    addWall("0292");
+    addWall("0343");
+    addWall("63:3");
+    addWall("2484");
+    addWall("0545");
+    addWall("65:5");
+    addWall("1797");
+    //addWall("08:8"); // bottom
+
+    // vert
+    addWall("5257");
+
+    addWall("1617");
+    addWall("2526");
+    addWall("3637");
+    addWall("4546");
+
+    addWall("6566");
+    addWall("7677");
+    addWall("8586");
+    addWall("9697");
+
+    this->setNoBall();     // reset all balls
     this->newBall();     // start first ball
     this->snd.play("T240 L16 O5 D E F");
-}
 
-
-void Game::initializePaddle()
-{
-    this->paddle.initialize(WIDTH / 2 - Game::PADDLE_WIDTH/2, HEIGHT - Game::PADDLE_HEIGHT, Game::PADDLE_WIDTH, Game::PADDLE_HEIGHT);
-    this->fDrawPaddle=true;
+    drawWalls();
 }
 
-
-void Game::updatePaddle()
-{
-    if (!this->left.read())  // note: read is LOW (0) when button pressed
-        this->paddle.move(Vector(-1 * Game::PADDLE_SPEED, 0));
-    else if (!this->right.read())
-        this->paddle.move(Vector(Game::PADDLE_SPEED, 0));
-    else
-    {
-        int i=this->checkTilt();
-        if(i>0)
-            this->paddle.move(Vector(Game::PADDLE_SPEED, 0));
-        else if(i<0)
-            this->paddle.move(Vector(-1 * Game::PADDLE_SPEED, 0));
-        else if(this->paddle.hasChanged())
-            paddle.move(Vector(0, 0));  // move to same place to restrict redraws
-    }
+Point Game::getGridPos(char *sPos)
+{   // get item pos based on a grid definition of 16x16 pixel squares, layed out in a 10x8 grid
+    // sPos is a 2 character string containing the coordinates in decimal notation: xy
+    int x=(sPos[0]-'0')*16+8;
+    int y=(sPos[1]-'0')*16+8;
+    return(Point(x,y));
 }
 
-void Game::redrawPaddle()
-{   // redraw the paddle when moved, or when forced by this->fDrawPaddle (set at bounce)
-    this->paddle.redraw(this->fDrawPaddle);
-    this->fDrawPaddle=false;
-}
-
-void Game::setNoBalls()
-{   // make sure no balls are active
-    for(int i=0; i<NUM_BALLS; i++)
-        this->aBalls[i].fActive=false;
-}
+void Game::addWall(char *sWall)
+{   // add a wall based on a grid definition of 16x16 pixel squares, layed out in a 10x8 grid
+    // sWall is a 4 character string containing the edge coordinates in decimal notation: xyXY
+    // grid axis range from x: '0'-'9', ':'=10  - y:  '0'-'8'
+    for(int i=0; i<NUM_WALLS; i++)
+    {
+        if(!aWalls[i].fActive)
+        {
+            int x1=sWall[0]-'0';
+            int y1=sWall[1]-'0';
+            int x2=sWall[2]-'0';
+            int y2=sWall[3]-'0';
+            aWalls[i].setRect(Rectangle(x1*16,y1*16,x2*16,y2*16));
+            aWalls[i].fActive=true;
+            printf(0, 0, "W: %d,%d - %d,%d", x1, y1, x2, y2);            
+            break;
 
-void Game::newBall()
-{   // add a new ball to the game
-    for(int i=0; i<NUM_BALLS; i++)
-    {
-        if(this->aBalls[i].fActive)
-            continue;
-        else
-        {
-            this->aBalls[i].initialize(WIDTH / 2 - Game::BALL_RADIUS, this->nTopWall + (HEIGHT-this->nTopWall) / 4 - Game::BALL_RADIUS, Game::BALL_RADIUS, Color565::fromRGB(i==0?0xFF:0x33, i==1?0xFF:0x33, i==2?0xFF:0x33));
-            //float ftRandX=rand() % 2 ? 1 : -1;
-            //float ftRandY=rand() % 2 ? 1 : -1;
-            //this->aBalls[i].setSpeed(ftRandX, ftRandY);
-            float ftRandX=((rand() % 20) - 10)/5.0;     // left/right at random speed
-            float ftRandY=((rand() % 10) - 10)/5.0;     // up at random speed
-            this->aBalls[i].vSpeed.set(ftRandX, ftRandY);
-            this->aBalls[i].fActive=true;
-            break;
+            //aWalls[i].draw();
+            //snd.beepShort();
         }
     }
 }
 
-void Game::updateBalls()
+void Game::drawWalls()
 {
-    for(int i=0; i<NUM_BALLS; i++)
-    {
-        if(!this->aBalls[i].fActive)
-            continue;
+    for(int i=0; i<NUM_WALLS; i++)
+        if(aWalls[i].fActive)
+        {
+            aWalls[i].draw();
+            //snd.beepShort();
+        }
+}
 
-        this->aBalls[i].update();                    // update the ball position 
 
-        // add downward gravity
-        if(this->aBalls[i].vSpeed.getSize()<10.0)
-            this->aBalls[i].vSpeed.add(this->vGravity);    // add some gravity
-
-    }
+void Game::setNoBall()
+{   // make sure no balls are active
+/*    for(int i=0; i<NUM_BALLS; i++)
+        this->aBalls[i].fActive=false;
+*/
 }
 
-void Game::redrawBalls()
-{
-    for(int i=0; i<NUM_BALLS; i++)
-    {
-        if(!this->aBalls[i].fActive)
-            continue;
-        this->aBalls[i].redraw();                    // update the ball position 
-    }
+void Game::newBall()
+{   // add a ball to the game
+    Point ptBall=getGridPos("01");
+    ball.initialize(ptBall.getX(), ptBall.getY(), Game::BALL_RADIUS, Color565::White);
+    //float ftRandX=rand() % 2 ? 1 : -1;
+    //float ftRandY=rand() % 2 ? 1 : -1;
+    //this->aBalls[i].setSpeed(ftRandX, ftRandY);
+//    float ftRandX=((rand() % 20) - 10)/5.0;     // left/right at random speed
+//    float ftRandY=((rand() % 10) - 10)/5.0;     // up at random speed
+//    ball.vSpeed.set(ftRandX, ftRandY);
+    //this->aBalls[i].fActive=true;
 }
 
-int Game::countBalls()
+void Game::updateBall()
+{
+    ball.update();                    // update the ball position 
+
+    // increase speed based on gravity
+    checkTilt();
+    if(ball.vSpeed.getSize()<1.0)
+        ball.vSpeed.add(this->vGravity);    // add some gravity
+        
+    // decrease speed based on friction
+    Vector vDecel=ball.vSpeed.getNormalized();
+    vDecel.multiply(vFriction);
+    ball.vSpeed.add(vDecel);
+}
+
+void Game::redrawBall()
+{
+    ball.redraw();                    // update the ball position 
+}
+
+int Game::countBall()
 {
     int nResult=0;
+/*
     for(int i=0; i<NUM_BALLS; i++)
     {
         if(this->aBalls[i].fActive)
             nResult++;
     }
+*/
     return(nResult);
 }
 
@@ -171,45 +200,48 @@
 
 void Game::tick()
 {  
-    this->checkButtons();
+    checkButtons();
     
-    if (this->mode) {
+    if(mode)
+    {
 /*
         if(this->tWait.read_ms()>100)
         {
-            this->updatePaddle();
             this->tWait.reset();
         }
 */
 
-        this->updateBalls();                    // update the ball positions
-        this->updatePaddle();
+        updateBall();                    // update the ball positions
     
-        this->checkPaddle();
-        this->checkBallsCollision();
+        checkBallCollision();
 
-        this->redrawBalls();
-        this->redrawPaddle();
-        this->redrawTopWall();
+        redrawBall();
+        
+        drawWalls();
         
 //        this->snd.checkPwm();
         //this->checkScore(); 
-        this->checkBalls(); 
+        //this->checkBall(); 
         
-        wait_ms(this->nGameTickDelay);  // can be adjusted using up/down
+        wait_ms(nGameTickDelay);  // can be adjusted using up/down
     }
-    else {
-        this->accel.updateGraph();
+    else
+    {
+        accel.updateGraph();
         wait_ms(100);
     } 
 }
 
-int Game::checkTilt()
-{    // move the paddle by tilting the board left or righr
+void Game::checkTilt()
+{    // move the gravity direction and weight by tilting the board
     double x, y, z;
     //int nStart=this->tWait.read_ms();
     this->accel.getXYZ(x, y, z);
 
+    vGravity=Vector(x,y);
+//    vGravity=vGravity.getNormalized();
+    
+    // TODO: make vector based on tilting
     //printDouble((double)this->tWait.read_ms()-nStart, 10, 10);
 /*
 printDouble(x, 0, 0);
@@ -218,9 +250,7 @@
 this->drawString(buf, DisplayN18::HEIGHT / 2 - DisplayN18::CHAR_HEIGHT / 2 + 4*DisplayN18::CHAR_HEIGHT ); 
 */
 
-    if(x<-0.1) return(-1);
-    else if(x>0.1) return(1);
-    else return(0);
+    //return(Vector(0,0));
 }
 
 void Game::checkButtons()
@@ -287,17 +317,16 @@
     
 }
 
-void Game::showSplashScreen() {
+void Game::showSplashScreen()
+{
     this->drawString(Game::SPLASH_1, HEIGHT / 2 - CHAR_HEIGHT / 2);  
     this->drawString(Game::SPLASH_2, HEIGHT / 2 + CHAR_HEIGHT / 2); 
     this->drawString(Game::SPLASH_3, HEIGHT / 2 + CHAR_HEIGHT / 2 + 2*CHAR_HEIGHT); 
-           
+
     while (this->circle.read())
     {
-int i=this->checkTilt();
-char buf[256];
-sprintf(buf,"  tilt:%d  ", i);
-this->drawString(buf, HEIGHT / 2 + CHAR_HEIGHT / 2 + (4*CHAR_HEIGHT) ); 
+checkTilt();
+printf(10, 150, "tilt: %.2f, %.2f  ", vGravity.x, vGravity.y);
 
         wait_ms(1);
     }
@@ -307,119 +336,54 @@
     this->initialize();     // start a new game
 }
 
-
-
-void Game::checkBallsCollision()
+void Game::checkBallCollision()
 {
     Rectangle rTop=Rectangle(0, -10, WIDTH, this->nTopWall);                // Rectangle(0, 0, WIDTH, 1);       // top wall
     Rectangle rBottom=Rectangle(0, HEIGHT, WIDTH, HEIGHT+10);  // Rectangle(0, HEIGHT, WIDTH, HEIGHT);       // bottom gap
     Rectangle rLeft=Rectangle(-10, 0, 0, HEIGHT);              // Rectangle(0, 0, 0, HEIGHT);       // left wall
     Rectangle rRight=Rectangle(WIDTH, 0, WIDTH+10, HEIGHT);       // Rectangle(WIDTH, 0, WIDTH, HEIGHT);       // right wall
-    Rectangle rPaddle=Rectangle(paddle.pos.getX(), paddle.pos.getY(), paddle.pos.getX() + Game::PADDLE_WIDTH, HEIGHT+10);       // Rectangle(this->paddleX, HEIGHT - Game::PADDLE_HEIGHT, this->paddleX + Game::PADDLE_WIDTH, HEIGHT);       // paddle
-    Rectangle rPaddleLeft=Rectangle(paddle.pos.getX(), paddle.pos.getY(), paddle.pos.getX() + Game::PADDLE_WIDTH/3, HEIGHT+10);      // paddle left part
-    Rectangle rPaddleRight=Rectangle(paddle.pos.getX()+ Game::PADDLE_WIDTH/3 + Game::PADDLE_WIDTH/3, paddle.pos.getY(), paddle.pos.getX() + Game::PADDLE_WIDTH, HEIGHT+10);      // paddle right part
-
-    Ball* pBall;
-    for(int i=0; i<NUM_BALLS; i++)
-    {
-        if(!this->aBalls[i].fActive)
-            continue;
-
-        pBall=&(this->aBalls[i]);
 
-        if(pBall->collides(rTop) && pBall->vSpeed.isUp())      // top wall
-        {
-            pBall->Bounce(Vector(1,-1));        // bounce vertical
-            this->snd.beepShort();
-            this->fDrawTopWall=true;
-        }
-        if(pBall->collides(rRight) && pBall->vSpeed.isRight())      // right wall
-        {
-            pBall->Bounce(Vector(-1,1));        // bounce horizontal
-            this->snd.beepShort();
-        }
-        if(pBall->collides(rLeft) && pBall->vSpeed.isLeft())      // left wall
-        {
-            pBall->Bounce(Vector(-1,1));        // bounce horizontal
-            this->snd.beepShort();
-        }
-        if(pBall->collides(rPaddle) && pBall->vSpeed.isDown())      // paddle
+    if(ball.collides(rTop) && ball.vSpeed.isUp())      // top wall
+    {
+        ball.vSpeed.y=0;
+        //this->snd.beepShort();
+    }
+    if(ball.collides(rRight) && ball.vSpeed.isRight())      // right wall
+    {
+        ball.vSpeed.x=0;
+        //this->snd.beepShort();
+    }
+    if(ball.collides(rLeft) && ball.vSpeed.isLeft())      // left wall
+    {
+        ball.vSpeed.x=0;
+        //this->snd.beepShort();
+    }
+    if(ball.collides(rBottom) && ball.vSpeed.isDown())      // bottom wall
+    {
+        ball.vSpeed.y=0;
+        //this->snd.beepShort();
+    }
+
+    for(int i=0; i<NUM_WALLS; i++)
+    {
+        if(aWalls[i].fActive)
         {
-            if(pBall->collides(rPaddleLeft))   pBall->vSpeed.add(Vector(-1.3,0));       // left side of paddle has bias to the left
-            if(pBall->collides(rPaddleRight))  pBall->vSpeed.add(Vector(1.3,0));       // right side of paddle has bias to the right
-    
-            // bounce the ball
-            // increase the speed of the ball when hitting the paddle to increase difficulty
-            float ftSpeedMax=3.0;
-            if(this->nScore>50)
-                ftSpeedMax=5.0;
-            if(this->nScore>100)
-                ftSpeedMax=10.0;
-            if(this->nScore>150)
-                ftSpeedMax=999.0;
-            if(pBall->vSpeed.getSize()<ftSpeedMax)
-                pBall->Bounce(Vector(1,-1.02));        // bounce from paddle at higher speed
-            else
-                pBall->Bounce(Vector(1,-1));        // bounce vertical at same speed
-    
-            // force drawing the paddle after redrawing the bounced ball
-            this->fDrawPaddle=true;
-
-            // make sound and update the score
-            this->snd.beepLong();
-            this->nScore++;
-            this->printf(100, 0, "Score: %d ", this->nScore);   
-
-            // add a new ball every 10 points
-            if(this->nScore>0 && this->nScore%10==0)
+            Rectangle rWall=aWalls[i].getRect();
+            if(ball.collides(rWall))
             {
-                this->newBall();
-                this->nBalls++;
-                this->snd.play("T240 L16 O5 D E F");
-            }
-
-            // lower the ceiling every 25 points
-            if(this->nScore>0 && this->nScore%25==0)
-            {
-                this->nTopWall+=3;
-                this->fDrawTopWall=true;
-                //this->snd.play("T240 L32 O5 GFEDC");
-                this->snd.play("T240 L16 O5 CDEFG");
+                //snd.play("T240 L128 O4 A");
+                if(rWall.isHorizontal())
+                    ball.Bounce(Vector(0,-0.1));
+                else
+                    ball.Bounce(Vector(-0.1,-0));
+                //ball.vSpeed.multiply(Vector(0,0));
+                aWalls[i].draw();
             }
-
-        }
-        if(pBall->collides(rBottom) && pBall->vSpeed.isDown())      // bottom gap
-        {
-            pBall->clearPrev();   // clear the ball from its previous position
-            pBall->clear();   // clear the ball from its current position
-            pBall->vSpeed.set(0,0);
-            pBall->fActive=false;
-            this->nBalls--;
-            if(countBalls()==0)
-            {
-                this->newBall();     // start a new ball
-                this->snd.beepLow();
-            }
+            //printf(0, 100, "W: %d,%d - %d,%d", rWall.getX1(), rWall.getY1(), rWall.getX2(), rWall.getY2());
         }
     }
-}
-
-void Game::redrawTopWall()
-{
-    if(this->fDrawTopWall)
-    {
-        int nTop=max(this->nTopWall-2, 8);
-        this->disp.fillRect(0, 8, WIDTH, nTop, Color565::Black);
-        this->disp.fillRect(0, nTop, WIDTH, this->nTopWall, Color565::Purple);
-        this->fDrawTopWall=false;
-    }
-}
-
-void Game::checkPaddle()
-{
-    Rectangle rScreen=Rectangle(0,0, WIDTH, HEIGHT);            // screen boundary
-
-    this->paddle.checkBoundary(rScreen);
+    
+    
 }
 
 
@@ -433,28 +397,3 @@
     va_end(args);
     this->disp.drawString(font_oem, x, y, szBuffer);
 }
-
-
-void Game::checkBalls()
-{
-    if (this->nBalls == 0)
-    {   // game over
-        char buf[256];
-        this->disp.clearScreen();
-
-        this->drawString(Game::LOSE_1, HEIGHT / 2 - CHAR_HEIGHT); 
-        this->drawString(Game::LOSE_2, HEIGHT / 2);  
-        sprintf(buf,"Your score: %d  ", this->nScore);
-        this->drawString(buf, HEIGHT / 2 + CHAR_HEIGHT / 2 + CHAR_HEIGHT ); 
-        
-        this->snd.playTune();
-        while (this->circle.read())
-            wait_ms(1);
-        wait_ms(250);   // el-cheapo deboounce
-        this->initialize();
-    }
-    else
-    {
-        this->printf(0, 0, "Balls: %d  ", this->nBalls);   
-    }
-}
\ No newline at end of file
--- a/Game.h	Thu Feb 05 14:41:21 2015 +0000
+++ b/Game.h	Sat Feb 28 11:40:39 2015 +0000
@@ -10,10 +10,10 @@
 #include "Accelerometer.h"
 #include "Shapes.h"
 #include "Ball.h"
-#include "Paddle.h"
+#include "Wall.h"
 
 
-#define NUM_BALLS 3
+#define NUM_WALLS 20
 
 class Game
 {
@@ -25,10 +25,7 @@
     //char buf[256];
     
     //static const int BALL_RADIUS = 3;
-    static const int BALL_RADIUS = 6;
-    static const int PADDLE_WIDTH = 38;
-    static const int PADDLE_HEIGHT = 4;
-    static const int PADDLE_SPEED = 4;
+    static const int BALL_RADIUS = 5;
     static const char I2C_ADDR = 0x1C << 1;
 
     DigitalIn left;
@@ -40,7 +37,7 @@
     DigitalOut led1;
     DigitalOut led2;
     AnalogIn ain;
-    I2C i2c;
+    //I2C i2c;
     LCD_ST7735 disp;
 
     SoundFX snd;
@@ -48,17 +45,14 @@
 //    Timer tWait;    // timer used for tickcounts
 
     Vector vGravity;
+    Vector vFriction;
     Ball ball;
-    Paddle paddle;
-    Ball aBalls[NUM_BALLS];
+    Wall aWalls[NUM_WALLS];
 
     bool mode;
+    int nTopWall;
     int nBalls;
     int nScore;
-    bool fDrawPaddle;
-    bool fDrawTopWall;
-    
-    int nTopWall;
 
     bool lastUp;
     bool lastDown;
@@ -67,34 +61,26 @@
     void printDouble(double value, int x, int y);
     
     void initialize();
+    Point getGridPos(char *sPos);
+    void addWall(char *sWall);
+    void drawWalls();
     
     void drawString(const char* str, int y);
+
+    void setNoBall();
+    void newBall();
+    void updateBall();
+    void redrawBall();
+    int countBall();
+    void checkBallCollision();
+    //void redrawTopWall();
     
-
-    void initializePaddle();
-    void updatePaddle();
-    void redrawPaddle();
-/*
-    void clearPaddle();
-    void drawPaddle();
-*/
-    //void initializeBall();
-    //void initializeBalls();
-    void setNoBalls();
-    void newBall();
-    void updateBalls();
-    void redrawBalls();
-    int countBalls();
-    void checkBallsCollision();
-    void redrawTopWall();
-    
-    int checkTilt();
+    void checkTilt();
     void checkButtons();
 
-    void checkPaddle();
     //void checkCollision();
     void printf(int x, int y, const char *szFormat, ...);
-    void checkBalls();
+    //void checkBall();
     
     public:
         Game();
--- a/MusicEngine.lib	Thu Feb 05 14:41:21 2015 +0000
+++ b/MusicEngine.lib	Sat Feb 28 11:40:39 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/taylorza/code/MusicEngine/#1742b6b435ff
+http://developer.mbed.org/users/taylorza/code/MusicEngine/#4f7c4255997a
--- a/Paddle.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#include "Paddle.h"
-
-Paddle::Paddle(LCD_ST7735* pDisp)
-{   // constructor
-    this->pDisp=pDisp;
-}
-
-Paddle::Paddle(LCD_ST7735* pDisp, int nX, int nY, int nWidth, int nHeight)
-{   // constructor
-    this->pos.set(nX, nY);
-    this->dim.nWidth=nWidth;
-    this->dim.nHeight=nHeight;
-    this->pDisp=pDisp;
-}
-
-void Paddle::initialize(int nX, int nY, int nWidth, int nHeight)
-{
-    this->pos.set(nX, nY);
-    this->dim.nWidth=nWidth;
-    this->dim.nHeight=nHeight;
-}
-
-void Paddle::checkBoundary(Rectangle rBoundary)
-{
-    if(pos.getX()<rBoundary.getX1())
-        pos.setX(rBoundary.getX1());
-    if(pos.getX()+dim.nWidth>rBoundary.getX2())
-        pos.setX(rBoundary.getX2()-dim.nWidth);
-}
-
-bool Paddle::hasChanged()
-{
-    return(pos.hasChanged());
-}
-
-void Paddle::move(Vector vDiff)
-{
-    this->pos.move(vDiff);
-//    this->rPaddle.move(vDiff);
-
-/*
-char szBuffer[256];
-sprintf(szBuffer, "p:%d,%d      ", pos.getX(), pos.getY());
-this->pDisp->drawString(font_oem, 0, 0, szBuffer);
-*/
-
-}
-
-
-void Paddle::clearPrev()
-{
-    Point p=pos.getPrev();
-    this->pDisp->fillRect(p.getX(), p.getY(), p.getX()+dim.nWidth, p.getY()+dim.nHeight, Color565::Black);    
-}
-
-void Paddle::clear()
-{
-    Point p=pos.getCur();
-    this->pDisp->fillRect(p.getX(), p.getY(), p.getX()+dim.nWidth, p.getY()+dim.nHeight, Color565::Black);    
-}
-
-void Paddle::draw()
-{
-    Point p=pos.getCur();
-    this->pDisp->drawLine(p.getX(), p.getY()+dim.nHeight, p.getX()+dim.nWidth/3, p.getY(), Color565::Blue);
-    this->pDisp->fillRect(p.getX()+dim.nWidth/3, p.getY(), p.getX()+dim.nWidth/3+dim.nWidth/3, p.getY()+dim.nHeight, Color565::Blue);
-    this->pDisp->drawLine(p.getX()+dim.nWidth/3+dim.nWidth/3, p.getY(), p.getX()+dim.nWidth, p.getY()+dim.nHeight, Color565::Blue);
-}
-
-void Paddle::redraw(bool fForceDraw)        // fForceDraw=false
-{   // redraw the paddle if its position has changed
-    //static int n=0;
-//char szBuffer[256];
-    
-    if(pos.hasChanged() || fForceDraw)
-    {
-        Point pPrev=pos.getPrev();
-        Point pCur=pos.getCur();
-/*
-n++;        
-sprintf(szBuffer, "%d %d,%d - %d,%d", n, pPrev.getX(), pPrev.getY(), pCur.getX(), pCur.getY());
-this->pDisp->drawString(font_oem, 20, 0, szBuffer);
-*/
-        clearPrev();
-        draw();
-    }
-}
\ No newline at end of file
--- a/Paddle.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#pragma once
-#include "mbed.h"
-
-#include "Color565.h"
-#include "font_OEM.h"
-#include "LCD_ST7735.h"
-
-#include "Shapes.h"
-#include "Vector.h"
-#include "Physics.h"
-
-class Paddle
-{
-    public:
-        Paddle(LCD_ST7735* pDisp);
-        Paddle(LCD_ST7735* pDisp, int nX, int nY, int nWidth, int nHeight);
-        void initialize(int nX, int nY, int nWidth, int nHeight);
-
-     
-        void move(Vector vDiff);
-        void checkBoundary(Rectangle rBoundary);
-        bool hasChanged();
-
-        void clearPrev();
-        void clear();
-        void draw();
-        void redraw(bool fForceDraw=false);
-
-        Position pos;
-        Dimension dim;
-        Vector vSpeed;
-
-
-
-    private:
-        LCD_ST7735* pDisp;
-};
\ No newline at end of file
--- a/Physics.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#include "Physics.h"
-
-Position::Position() : vPos(), pPrev(), pCur()
-{   // constructor
-
-}
-
-Point Position::getPrev()
-{
-    return(pPrev);
-}
-
-Point Position::getCur()
-{
-    return(pCur);
-}
-
-int Position::getX()
-{
-    return(pCur.getX());
-}
-int Position::getY()
-{
-    return(pCur.getY());
-}
-
-void Position::set(float x, float y)
-{
-    //nPrevX=nCurX;
-    //nPrevY=nCurY;
-    pPrev=pCur;
-    vPos.x=x;
-    vPos.y=y;
-    pCur.set(rint(vPos.x), rint(vPos.y));
-    //nCurX=rint(vPos.x);
-    //nCurY=rint(vPos.y);
-}
-
-void Position::set(int x, int y)
-{
-    set((float)x, (float)y);
-}
-
-void Position::set(Point ptNew)
-{
-    set(ptNew.getX(), ptNew.getY());
-}
-
-void Position::setX(int x)
-{
-    set((float)x, vPos.y);
-}
-
-void Position::setY(int y)
-{
-    set(vPos.x, (float)y);
-}
-
-void Position::move(float fDiffX, float fDiffY)
-{
-    //nPrevX=nCurX;
-    //nPrevY=nCurY;
-    pPrev=pCur;
-    vPos.x+=fDiffX;
-    vPos.y+=fDiffY;
-    pCur.set(rint(vPos.x), rint(vPos.y));
-    //nCurX=rint(vPos.x);
-    //nCurY=rint(vPos.y);
-}
-
-void Position::move(int nDiffX, int nDiffY)
-{
-    move((float)nDiffX, (float)nDiffY);
-}
-
-void Position::move(Vector vDiff)
-{
-    move(vDiff.x, vDiff.y);
-}
-
-bool Position::hasChanged()
-{
-    //return(nPrevX!=nCurX || nPrevy!=nCury);
-    return(pPrev.getX()!=pCur.getX() || pPrev.getY()!=pCur.getY());
-}
-
-Dimension::Dimension()
-{
-    nWidth=0;
-    nHeight=0;
-}
\ No newline at end of file
--- a/Physics.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#pragma once
-#include "mbed.h"
-#include "Vector.h"
-#include "Shapes.h"
-
-class Position
-{
-    public:
-        Position();
-        Point getPrev();
-        Point getCur();
-        int getX();
-        int getY();
-
-        void set(float x, float y);
-        void set(int x, int y);
-        void set(Point ptNew);
-        void setX(int x);
-        void setY(int y);
-
-        void move(float fDiffX, float fDiffY);
-        void move(int nDiffX, int nDiffY);
-        void move(Vector vDiff);
-        bool hasChanged();
-    private:
-        Vector vPos;
-        Point pPrev;
-        Point pCur;
-};
-
-class Dimension
-{
-    public:
-        Dimension();
-        int nWidth;
-        int nHeight;
-};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RETRO_BallsAndThings.lib	Sat Feb 28 11:40:39 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/maxint/code/RETRO_BallsAndThings/#f421e34313d3
--- a/Shapes.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-#include "mbed.h"
-#include "Shapes.h"
-
-
-
-///////////////////
-// POINT
-///////////////////
-Point::Point()
-{   // constructor
-    x1=0;
-    y1=0;
-}
-
-Point::Point(int x, int y)
-{   // constructor
-    x1=x;
-    y1=y;
-}
-
-int Point::getX()
-{
-    return x1;
-}
-
-int Point::getY()
-{
-    return y1;
-}
-
-void Point::set(int x, int y)
-{
-    x1=x;
-    y1=y;
-}
-
-
-///////////////////
-// RECTANGLE
-///////////////////
-
-Rectangle::Rectangle(int x,int y, int xx, int yy)
-{
-    x1 = x;
-    x2 = xx;
-    y1 = y;
-    y2 = yy;
-}
-
-Rectangle::Rectangle(Point pt1, Point pt2)
-{
-    x1 = pt1.getX();
-    x2 = pt2.getX();
-    y1 = pt1.getY();
-    y2 = pt2.getY();
-}
-
-
-bool Rectangle::collides(Point pt)
-{
-    if(pt.getX() >= x1 && pt.getX() <= x2) {
-        if(pt.getY() >= y1 && pt.getY() <= y2) {
-            return true;
-        }
-    }
-    return false;
-}
-
-/*
-Rectangle Rectangle::intersection(Rectangle r)
-{   // return the intersection of two rectangles or null
-    Rectangle rResult;
-    rResult=Rectangle()
-    if(this->x2 >= 
-}
-*/
-
-bool Rectangle::collides(Rectangle r)
-{   // check if two rectangles collide
-    // method 1: check if corners of eithter rectangle collide
-    // method 2: compare sides
-    if(this->collides(r.get1()) || this->collides(r.get2())) return(true);
-    if(this->collides(r.get3()) || this->collides(r.get4())) return(true);
-    if(r.collides(this->get1()) || r.collides(this->get2())) return(true);
-    if(r.collides(this->get3()) || r.collides(this->get4())) return(true);
-    // TODO: check other corners
-    return(false);
-}
-
-
-Point Rectangle::get1()
-{
-    return(Point(x1, y1));
-}
-
-Point Rectangle::get2()
-{
-    return(Point(x2, y2));
-}
-
-Point Rectangle::get3()
-{
-    return(Point(x2, y1));
-}
-
-Point Rectangle::get4()
-{
-    return(Point(x1, y2));
-}
- 
-
- 
-int Rectangle::getX1()
-{
-    return x1;
-}
- 
-int Rectangle::getX2()
-{
-    return x2;
-}
- 
-int Rectangle::getY1()
-{
-    return y1;
-}
- 
-int Rectangle::getY2()
-{
-    return y2;
-}
- 
-int Rectangle::getCenterX()
-{
-    return x1 + (x2-x1)/2;
-}
- 
-int Rectangle::getCenterY()
-{
-    return y1 + (y2-y1)/2;
-}
-
-Point Rectangle::getCenter()
-{
-    return(Point(x1 + (x2-x1)/2, y1 + (y2-y1)/2));
-}
-
-void Rectangle::set(Rectangle rNew)
-{
-    x1=rNew.getX1();
-    y1=rNew.getY1();
-    x2=rNew.getX2();
-    y2=rNew.getY2();
-}
-
-void Rectangle::move(Vector v)
-{
-    x1+=rint(v.x);
-    y1+=rint(v.y);
-    x2+=rint(v.x);
-    y2+=rint(v.y);
-}
-
-
-///////////////////
-// CIRCLE
-///////////////////
-Circle::Circle(int x,int y, int r)
-{
-    x1=x;
-    y1=y;
-    r1=r;
-}
-
-Point Circle::getCenter()
-{
-    return(Point(x1, y1));
-}
-
-int Circle::getRadius()
-{
-    return(r1);
-}
-
-int Circle::getX()
-{
-    return(x1);
-}
-
-int Circle::getY()
-{
-    return(y1);
-}
-
-void Circle::setX(int x)
-{
-    x1=x;
-}
-
-void Circle::setY(int y)
-{
-    y1=y;
-}
-
-void Circle::setXY(int x, int y)
-{
-    x1=x;
-    y1=y;
-}
-
-void Circle::move(int x, int y)
-{
-    x1+=x;
-    y1+=y;
-}
-
-void Circle::move(Vector v)
-{
-    x1+=rint(v.x);
-    y1+=rint(v.y);
-}
-
-
-Rectangle Circle::getBoundingRectangle()
-{
-    return(Rectangle(x1-r1, y1-r1, x1+r1, y1+r1));
-}
--- a/Shapes.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#pragma once
-#include "mbed.h"
-#include "Vector.h"
-
-class Point
-{ 
-protected :
-    int x1, y1;
-
-public :
-    Point();
-    Point(int x, int y);
-    int getX();
-    int getY();
-    void set(int x, int y);
-};
-
-class Rectangle
-{
-protected :
-    int x1, x2, y1, y2;
- 
-public :
-    Rectangle(int x,int y, int x2, int y2);
-    Rectangle(Point pt1, Point pt2);
-    bool collides(Point pt);
-    bool collides(Rectangle r);
-
-    void set(Rectangle rNew);
-    
-    Point get1();
-    Point get2();
-    Point get3();
-    Point get4();
-    Point getCenter();
-
-    int getX1();
-    int getX2();
-    int getY1();
-    int getY2();
-    int getCenterX();
-    int getCenterY();
-    void move(Vector v);
-};
-
-class Circle
-{ 
-protected :
-    int x1, y1, r1;
-
-public :
-    Circle(int x,int y, int r);
-    Point getCenter();
-    int getRadius();
-    int getX();
-    int getY();
-    void setX(int x);
-    void setY(int y);
-    void setXY(int x, int y);
-    void move(int x, int y);
-    void move(Vector v);
-    Rectangle getBoundingRectangle();
-};
-
--- a/SoundFX.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#pragma once
-#include "mbed.h"
-#include "MusicEngine.h"
-
-class SoundFX
-{
-    public:
-        SoundFX();
-        void checkPwm();
-        void reset();
-        void beep(int nDuration=1);
-        void beepShort();
-        void beepLong();
-        void beepLow();
-        void play(char *szPlay);
-        void playTune();        
-        void setMute(bool fMute);
-        bool getMute();
-
-        void musicCompleted(void);
-
-    private:
-        static const int BOUNCE1_SOUND_TICKS = 1;
-        static const int BOUNCE2_SOUND_TICKS = 2;
-
-//        PwmOut pwm;
-//        int pwmTicksLeft;
-        bool fMute;
-        MusicEngine music;
-        
-};
--- a/SoundFx.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-#include "SoundFX.h"
-
-SoundFX::SoundFX() :
-// pwm(P0_18),
- music(P0_18)
-{
-//    this->pwmTicksLeft=0;
-    this->fMute=false;
-    music.setCompletionCallback(this, &SoundFX::musicCompleted);
-}
-
-void SoundFX::checkPwm()
-{
-/*
-    if(this->fMute || this->pwmTicksLeft == 0)
-        this->pwm.write(0.0);
-    else
-    {
-        this->pwmTicksLeft--;
-        this->pwm.write(0.5); 
-    }
-*/
-}
-
-void SoundFX::musicCompleted(void)
-{
-/*
-    PwmOut pwm(P0_18);
-    pwm = 0.0;
-    pwm.period(0.1);
-    pwm.write(0.00);
-*/
-}
-
-void SoundFX::reset()
-{
-/*
-    this->pwmTicksLeft=0;
-
-    this->pwm.period_ms(1);
-    this->pwm.write(0.00);
-*/
-/*
-    PwmOut pwm(P0_18);
-    pwm.write(0.00);
-*/
-}
-
-void SoundFX::setMute(bool fMute)
-{
-    this->fMute=fMute;
-}
-
-
-bool SoundFX::getMute()
-{
-    return(this->fMute);
-}
-
-
-void SoundFX::beep(int nDuration)       //nDuration=1
-{
-    if(this->fMute)
-        return;
-//    this->pwmTicksLeft = nDuration;
-}
-
-void SoundFX::beepShort()
-{
-    if(this->fMute)
-        return;
-/*
-    this->pwm.period_ms(2);
-    this->pwmTicksLeft = SoundFX::BOUNCE1_SOUND_TICKS;
-*/
-    music.play("T240 L32 O6 C");
-}
-
-void SoundFX::beepLong()
-{
-    if(this->fMute)
-        return;
-
-/*
-    this->pwm.period_ms(1);
-    this->pwmTicksLeft = SoundFX::BOUNCE2_SOUND_TICKS;
-*/
-    music.play("T240 L8 O5 C");
-}
-
-void SoundFX::beepLow()
-{
-    if(this->fMute)
-        return;
-/*
-    this->pwm.period(1.0/220);
-    this->pwm.write(0.5);
-    wait_ms(150);
-    this->pwm.write(0.0);
-*/
-    music.play("T180 L4 O3 C");
-}
-
-void SoundFX::play(char *szPlay)
-{
-    if(this->fMute)
-        return;
-    music.play(szPlay);
-}
-
-void SoundFX::playTune()
-{
-    if(this->fMute)
-        return;
-/*
-    this->pwm.period(1.0/220);
-    this->pwm.write(0.5);
-    wait_ms(150);
-    this->pwm.write(0.0);
-    
-    this->pwm.period(1.0/196);
-    this->pwm.write(0.5);
-    wait_ms(150);
-    this->pwm.write(0.0);
-    
-    this->pwm.period(1.0/164.81);
-    this->pwm.write(0.5);
-    wait_ms(150);
-    this->pwm.write(0.0);
-*/
-//    music.setCompletionCallback(this, &SoundFX::musicCompleted);
-    //music.play("T224L8O5CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16L8C#L16>C#<P16G#P16L8FL16P16>C#<G#P16L8F.L16P16L8CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16D#EFP16FF#GP16GG#AP16L8>C<P8L4>C");
-    music.play("T120 O3 L16 F L4 C F L8 C");
-
-}
\ No newline at end of file
--- a/Vector.cpp	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#include "Vector.h"
-
-Vector::Vector()
-{   // constructor
-    this->set((float)0,(float)0);
-}
-
-Vector::Vector(float fX, float fY)
-{
-    this->set(fX, fY);
-}
-
-void Vector::set(float fX, float fY)
-{
-    x=fX;
-    y=fY;
-}
-void Vector::set(int nX, int nY)
-{
-    this->set((float)nX, (float)nY);
-}
-
-float Vector::getSize()
-{   // get the size of the vector
-    return(sqrt(x*x+y*y));
-}
-
-bool Vector::isLeft()  { return(x<0); }
-bool Vector::isRight() { return(x>0); }
-bool Vector::isUp()    { return(y<0); }
-bool Vector::isDown()  { return(y>0); }
-
-
-void Vector::add(float fAdd)
-{   // add the size of the vector by adding to its size
-    float fSize=getSize();
-    float fSizeNew=fSize+fAdd;
-    if(fSize!=0)
-    {
-        x=x * (fSizeNew/fSize);
-        y=y * (fSizeNew/fSize);
-    }
-    else
-    {   // in case of zero lenght, default to addition in first quadrant.
-        x=sqrt(0.5 * fAdd * fAdd);
-        y=x;
-    }
-}
-
-void Vector::add(Vector vAdd)
-{
-    x+=vAdd.x;
-    y+=vAdd.y;
-}
-
-void Vector::multiply(Vector vMult)
-{   // multiply the vector by means of the other vector
-    x*=vMult.x;
-    y*=vMult.y;
-}
\ No newline at end of file
--- a/Vector.h	Thu Feb 05 14:41:21 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#pragma once
-#include "mbed.h"
-
-class Vector
-{
-    public:
-        float x;
-        float y;
-        
-        Vector();
-        Vector(float fX, float fY);
-        void set(float dX, float fY);
-        void set(int nX, int nY);
-        float getSize();
-        bool isLeft();
-        bool isRight();
-        bool isUp();
-        bool isDown();
-        void add(float fAdd);
-        void add(Vector vAdd);
-        void multiply(Vector vMult);
-};