This a Library that can be used to make ping pong the Nokia Lcd 5110.
Diff: Paddle.cpp
- Revision:
- 0:ef8d5a4464a3
- Child:
- 1:4893a8f7147f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paddle.cpp Wed May 04 23:22:04 2016 +0000 @@ -0,0 +1,77 @@ +/** +** +@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(); +} + +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; + } + } +}