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.
Dependencies: mbed
surface.h
00001 #ifndef LINE_H 00002 #define LINE_H 00003 00004 #include "mbed.h" 00005 /** Line struct */ 00006 struct Line { 00007 int length;/**< the length of the line. */ 00008 int left;/**< the leftside of the line. */ 00009 int right;/**< the rightside of the line. */ 00010 int y;/**< the height of the line. */ 00011 }; 00012 00013 //the line structer will have four main elements 00014 00015 /** surface Class 00016 * @1 the leftside of the line move toward right then the rightside should also move to the right to keep the length 00017 * @2 the line will be random length but must be suitable 00018 * @3 makesure there are two surface for player to stay 00019 * @date April 22th 2020 00020 * @author Yaomochu 00021 00022 @code 00023 00024 #include "mbed.h" 00025 #include "N5110.h" 00026 #include "Gamepad.h" 00027 #include "surface.h" 00028 #include <cstdlib> 00029 #include <ctime> 00030 00031 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 00032 Gamepad gamepad; 00033 Surface _surface; 00034 00035 Line line_1_value; 00036 Line line_2_value; 00037 Line line_3_value; 00038 Line line_4_value; 00039 Line line_5_value; 00040 Line line_6_value; 00041 00042 int main() { 00043 _surface.init(20,40); 00044 while(1) { 00045 //draw line 1 00046 _surface.line_1(); 00047 line_1_value = _surface.getline_1(); 00048 lcd.drawLine(line_1_value.left,line_1_value.y,line_1_value.right,line_1_value.y,FILL_BLACK); 00049 //draw line 2 00050 _surface.line_2(); 00051 line_2_value = _surface.getline_2(); 00052 lcd.drawLine(line_2_value.left,line_2_value.y,line_2_value.right,line_2_value.y,FILL_BLACK); 00053 //draw line 3 00054 _surface.line_3(); 00055 line_3_value = _surface.getline_3(); 00056 lcd.drawLine(line_3_value.left,line_3_value.y,line_3_value.right,line_3_value.y,FILL_BLACK); 00057 //draw line 4 00058 _surface.line_4(); 00059 line_4_value = _surface.getline_4(); 00060 lcd.drawLine(line_4_value.left,line_4_value.y,line_4_value.right,line_4_value.y,FILL_BLACK); 00061 //draw line 5 00062 _surface.line_5(); 00063 line_3_value = _surface.getline_5(); 00064 lcd.drawLine(line_5_value.left,line_5_value.y,line_5_value.right,line_5_value.y,FILL_BLACK); 00065 //draw line 6 00066 _surface.line_6(); 00067 line_6_value = _surface.getline_6(); 00068 lcd.drawLine(line_6_value.left,line_6_value.y,line_6_value.right,line_6_value.y,FILL_BLACK); 00069 } 00070 } 00071 00072 @endcode 00073 */ 00074 00075 class Surface 00076 { 00077 public: 00078 // Constructor and Destructor. 00079 /** 00080 * @brief Constructor @details Non user specified. 00081 */ 00082 Surface(); 00083 /** 00084 * @brief Destructor @details Non user specified. 00085 */ 00086 ~Surface(); 00087 /** 00088 * @brief init the line at first to set the initial position. 00089 * @param y1 @details the lower line height. 00090 * @param y2 @details the upper line height. 00091 */ 00092 void init(int y1, int y2); 00093 /** 00094 * @brief set line1 movement. 00095 */ 00096 void line_1(); 00097 /** 00098 * @brief set line2 movement. 00099 */ 00100 void line_2(); 00101 /** 00102 * @brief set line3 movement. 00103 */ 00104 void line_3(); 00105 /** 00106 * @brief set line4 movement. 00107 */ 00108 void line_4(); 00109 /** 00110 * @brief set line5 movement. 00111 */ 00112 void line_5(); 00113 /** 00114 * @brief set line6 movement. 00115 */ 00116 void line_6(); 00117 // Accessors. 00118 /** 00119 * @brief Gets line 1. 00120 * @returns Line 1 (type: struct, Line) 00121 */ 00122 Line getline_1(); 00123 /** 00124 * @brief Gets line 2. 00125 * @returns Line 2 (type: struct, Line) 00126 */ 00127 Line getline_2(); 00128 /** 00129 * @brief Gets line 3. 00130 * @returns Line 3 (type: struct, Line) 00131 */ 00132 Line getline_3(); 00133 /** 00134 * @brief Gets line 4. 00135 * @returns Line 4 (type: struct, Line) 00136 */ 00137 Line getline_4(); 00138 /** 00139 * @brief Gets line 5. 00140 * @returns Line 5 (type: struct, Line) 00141 */ 00142 Line getline_5(); 00143 /** 00144 * @brief Gets line 6. 00145 * @returns Line 6 (type: struct, Line) 00146 */ 00147 Line getline_6(); 00148 00149 private: 00150 Line _line_1; 00151 Line _line_2; 00152 Line _line_3; 00153 Line _line_4; 00154 Line _line_5; 00155 Line _line_6; 00156 00157 }; 00158 #endif 00159
Generated on Thu Jul 14 2022 07:54:31 by
