This a Library that can be used to make ping pong the Nokia Lcd 5110.

Paddle.cpp

Committer:
el14jpps
Date:
2016-05-05
Revision:
1:4893a8f7147f
Parent:
0:ef8d5a4464a3

File content as of revision 1:4893a8f7147f:

/**
**
@file Paddle.cpp
@brief File containing all the functions prototypes, void etc for the ball.
@brief Shows examples of creating Doxygen documentation.
@brief Revision 1.0.
@author Jefferson Sanchez
@date April 2016
*/

#include "Paddle.h"
int Paddle::lookforX1()// as the function states the integer needed will change in x1,x2,y1,y2
{
    return x1;
}

int Paddle::lookforX2()
{
    return x2;
}

int Paddle::lookforY1()
{
    return y1;
}

int Paddle::lookforY2()
{
    return y2;
}

void Paddle::YPaddle(N5110 &display)
{
    for(int i = y1; i <= y2; i++)
    {
        display.setPixel(x1, i);
        display.setPixel(x2, i);
    }
    
    display.refresh();
}

void Paddle::Moving_Paddle(N5110 &display) // used for the movement of the paddles.
{
    for(int i = y1; i <= y2; i++)
    {
        display.clearPixel(x1, i);
        display.clearPixel(x2, i);
    }
    
    display.refresh();
}
 /**@code Dr Evans - The joystick code provided on the labs was used to obtain the values to move the paddels and for the menu */
void Paddle::Refresh_pos(AnalogIn &p1)// in this void we can see the uodate of the paddle for player 1 
{
     // 
     if (p1 < 0.33)/**The  threshold of potentiometer P1 , the 0.33 value was obtained using Dr Evans code for the joystick and cool term*/
    {
        y1 -= 2;
        y2 -= 2;
        if(y1 < 0 or y2 < 7){
            y1 = 0;
            y2 = 7;
        }
    }
    
    if (p1 > 0.66)/**The  threshold of potentiometer P2 , the 0.66 value was obtained using Dr Evans code for the joystick and cool term*/
    {
        y1 += 2;
        y2 += 2;
        if(y2 > 47 or y1 > 40)
        {
            y2 = 47;
            y1 = 40;
        }
    }
}