Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Paddle.cpp
00001 /** 00002 ** 00003 @file Paddle.cpp 00004 @brief File containing all the functions prototypes, void etc for the ball. 00005 @brief Shows examples of creating Doxygen documentation. 00006 @brief Revision 1.0. 00007 @author Jefferson Sanchez 00008 @date April 2016 00009 */ 00010 00011 #include "Paddle.h" 00012 int Paddle::lookforX1()// as the function states the integer needed will change in x1,x2,y1,y2 00013 { 00014 return x1; 00015 } 00016 00017 int Paddle::lookforX2() 00018 { 00019 return x2; 00020 } 00021 00022 int Paddle::lookforY1() 00023 { 00024 return y1; 00025 } 00026 00027 int Paddle::lookforY2() 00028 { 00029 return y2; 00030 } 00031 00032 void Paddle::YPaddle(N5110 &display) 00033 { 00034 for(int i = y1; i <= y2; i++) 00035 { 00036 display.setPixel(x1, i); 00037 display.setPixel(x2, i); 00038 } 00039 00040 display.refresh(); 00041 } 00042 00043 void Paddle::Moving_Paddle(N5110 &display) // used for the movement of the paddles. 00044 { 00045 for(int i = y1; i <= y2; i++) 00046 { 00047 display.clearPixel(x1, i); 00048 display.clearPixel(x2, i); 00049 } 00050 00051 display.refresh(); 00052 } 00053 /**@code Dr Evans - The joystick code provided on the labs was used to obtain the values to move the paddels and for the menu */ 00054 void Paddle::Refresh_pos(AnalogIn &p1)// in this void we can see the uodate of the paddle for player 1 00055 { 00056 // 00057 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*/ 00058 { 00059 y1 -= 2; 00060 y2 -= 2; 00061 if(y1 < 0 or y2 < 7){ 00062 y1 = 0; 00063 y2 = 7; 00064 } 00065 } 00066 00067 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*/ 00068 { 00069 y1 += 2; 00070 y2 += 2; 00071 if(y2 > 47 or y1 > 40) 00072 { 00073 y2 = 47; 00074 y1 = 40; 00075 } 00076 } 00077 }
Generated on Thu Jul 21 2022 10:50:37 by
1.7.2