跑酷天堂C++小黑框版

上:跳躍c++

左右:行走windows

 1 #include <bits/stdc++.h>
 2 #include <windows.h>
 3 #include <conio.h>
 4 
 5 using namespace std;  6 
 7 char mmp[1001][1001] = {"                                                                                                                                                                                                        ",  8                         "                                                                                                                                                                                                        ",  9                         " ### # # # # # # # ### #### ### ",  10                         " ## #### ### # # # # ### ## ",  11                         " ## ##### #### ### ",  12                         " ## ## ",  13                         " #### ",  14                         " ### ",  15                         " ## ",  16                         " ####",  17                         "                                                                                                                                                                                                        ",  18                         " ## ### ",  19                         " ## #### ",  20                         " ### #### ",  21                         " ### ## ",  22                         "                                                                                                                                                                                                        ",  23                         " O ",  24                         "##### ",  25                         "##### ",  26                         "##### "
 27                        };//20 * 200;
 28 
 29 char putmmp[20][16];  30 
 31 int jump[20] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1};  32 
 33 int main() {  34 
 35     char ch;  36     
 37     bool t = 1;  38 
 39     int x = 16, y = 2, delayjump = 0;  40     
 41     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);  42     
 43     while (1) {  44 
 45         Sleep(40);  46 
 47         if (y - 7 < 0) {  48 
 49             for (register int i = 0; i < 20; i++) {  50 
 51                 for (register int j = 0; j < 15; j++) {  52 
 53                     putmmp[i][j] = mmp[i][j];  54 
 55  }  56 
 57  }  58 
 59         } else if (y + 7 > 199) {  60 
 61             for (register int i = 0; i < 20; i++) {  62 
 63                 int k = 14;  64 
 65                 for (register int j = 199; j >= 85; j--, k--) {  66 
 67                     putmmp[i][k] = mmp[i][j];  68 
 69  }  70 
 71  }  72 
 73         } else {  74 
 75             for (register int i = 0; i < 20; i++) {  76 
 77                 int k = 0;  78 
 79                 for (register int j = y - 7; j <= y + 7; j++, k++) {  80 
 81                     putmmp[i][k] = mmp[i][j];  82 
 83  }  84 
 85  }  86 
 87  }  88         
 89  HANDLE hout;  90  COORD coord;  91         coord.X=0;  92         coord.Y=0;  93         hout=GetStdHandle(STD_OUTPUT_HANDLE);  94  SetConsoleCursorPosition(hout,coord);  95         
 96         for (register int i = 0; i < 20; i++) {  97             
 98             bool t = 0;  99             
100             for (register int j = 0; j < 15; j++) { 101                 
102                 if (putmmp[i][j] == 'O') { 103                     
104                     t = 1; 105                     
106  } 107                 
108  } 109             
110             if (t) { 111                 
112                 for (register int j = 0; j < 15; j++) { 113                     
114                     if (putmmp[i][j] == 'O') { 115                         
116  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED); 117                         putchar('O'); 118                         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN); 119                         
120                     } else { 121                         
122  putchar(putmmp[i][j]); 123                         
124  } 125                     
126  } 127                 
128                 putchar('\n'); 129                 
130             } else { 131                 
132  puts(putmmp[i]); 133                 
134  } 135             
136  } 137         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); 138         printf("%d %d\n", x, y); 139         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN); 140 
141         if (delayjump > 0) { 142 
143             if (delayjump > 8 && (x + jump[delayjump] == -1 || mmp[x + jump[delayjump]][y] == '#')) { 144 
145                 delayjump = 5; 146 
147             } else { 148                 
149                 if (delayjump <= 8 && x + jump[delayjump] == 19) { 150                     
151                     mmp[x][y] = ' '; 152                     x = 16, y = 2; 153                     mmp[x][y] = 'O'; 154                     
155  } 156                 
157                 if (delayjump <= 8 && (x + jump[delayjump] == 20 || mmp[x + jump[delayjump]][y] == '#')) { 158 
159                     delayjump = 0; 160 
161                 } else { 162 
163                     mmp[x][y] = ' '; 164                     x += jump[delayjump]; 165                     mmp[x][y] = 'O'; 166                     delayjump--; 167 
168  } 169 
170  } 171 
172 
173  } 174         
175         if (!delayjump) { 176             
177             if (x + 1 == 20) { 178                 
179                 mmp[x][y] = ' '; 180                 x = 16, y = 2; 181                 mmp[x][y] = 'O'; 182                 
183  } 184             
185             if (mmp[x + 1][y] == ' ' && x < 19 && t) { 186                 
187                 t = !t; 188                 mmp[x][y] = ' '; 189                 x++; 190                 mmp[x][y] = 'O'; 191                 
192             } else { 193                 
194                 t = !t; 195                 
196  } 197             
198  } 199 
200         if (kbhit()) { 201 
202             ch = getch(); 203 
204             switch(ch) { 205 
206                 case 27 : 207 
208                     exit(0); 209 
210                     break; 211 
212                 case -32 : 213 
214                     ch = getch(); 215 
216                     switch(ch) { 217 
218                         case 75 : 219 
220                             if (y > 0 && mmp[x][y - 1] == ' ') { 221 
222                                 mmp[x][y] = ' '; 223                                 y--; 224                                 mmp[x][y] = 'O'; 225 
226  } 227 
228                             break; 229 
230                         case 77 : 231 
232                             if (y < 199 && mmp[x][y + 1] == ' ') { 233 
234                                 mmp[x][y] = ' '; 235                                 y++; 236                                 mmp[x][y] = 'O'; 237 
238  } 239 
240                             break; 241 
242                         case 72 : 243 
244                             if (!delayjump && mmp[x + 1][y] == '#') { 245 
246                                 delayjump = 18; 247 
248  } 249 
250                             break; 251 
252  } 253 
254                     break; 255 
256  } 257 
258  } 259 
260  } 261 
262     return 0; 263 
264 }

 自動版:spa

 

 1 #include <bits/stdc++.h>
 2 #include <conio.h>
 3 #include <windows.h>
 4 
 5 using namespace std;  6 
 7 char mmp[1001][1001] = {"                                                                                                    ",  8                         "                                                                                                    ",  9                         " #### ",  10                         " # ",  11                         " ### ### ##### ",  12                         " #### #### ",  13                         " # ### ### ",  14                         " #### ## #### ",  15                         "O #### ###### ",  16                         "##### #"
 17  };  18 
 19 char putmmp[101][101];  20 int jp[9] = {0, 1, 0, 1, 0, 1, 0, 1, 1};  21 
 22 int main() {  23 
 24     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN);  25 
 26     int x = 8, y = 0, dj = 0, tick = 0;  27 
 28     int clock2 = clock();  29 
 30     while (1) {  31 
 32         int clock1 = clock();  33         clock2 = clock1;  34 
 35         while (clock1 - clock2 <= 70) {  36 
 37             Sleep(10);  38             clock1 = clock();  39 
 40  }  41 
 42 
 43         if (y < 7) {  44 
 45             for (register int i = 0; i < 10; i++) {  46 
 47                 for (register int j = 0; j < 15; j++) {  48 
 49                     putmmp[i][j] = mmp[i][j];  50 
 51  }  52 
 53  }  54 
 55         } else if (y > 92) {  56 
 57             for (register int i = 0; i < 10; i++) {  58 
 59                 for (register int j = 84, k = 0; j < 100; j++, k++) {  60 
 61                     putmmp[i][k] = mmp[i][j];  62 
 63  }  64 
 65  }  66 
 67         } else {  68 
 69             for (register int i = 0; i < 10; i++) {  70 
 71                 for (register int j = y - 7, k = 0; j < y + 7; j++, k++) {  72 
 73                     putmmp[i][k] = mmp[i][j];  74 
 75  }  76 
 77  }  78 
 79  }  80 
 81  HANDLE hout;  82  COORD coord;  83         coord.X=0;  84         coord.Y=0;  85         hout=GetStdHandle(STD_OUTPUT_HANDLE);  86  SetConsoleCursorPosition(hout,coord);  87 
 88         for (register int i = 0; i < 10; i++) {  89 
 90             if (i ^ x) {  91 
 92  puts(putmmp[i]);  93 
 94             } else {  95 
 96                 for (register int j = 0; j < 15; j++) {  97 
 98                     if (putmmp[i][j] == 'O') {  99 
100  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); 101 
102                         putchar('O'); 103 
104                         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN); 105 
106                     } else { 107 
108  putchar(putmmp[i][j]); 109 
110  } 111 
112  } 113 
114                 putchar('\n'); 115 
116  } 117 
118  } 119 
120         printf("%d\n", y); 121 
122         if (kbhit()) { 123 
124             char ch = getch(); 125 
126             if (ch == ' ' && (mmp[x + 1][y] == '#' || mmp[x + 1][y - 1] == '#')) { 127 
128                 dj = 8; 129 
130  } 131 
132             if (ch == 27) { 133 
134                 exit(0); 135 
136  } 137 
138  } 139 
140         if (dj > 0) { 141 
142             if (x - jp[dj] >= 0 && mmp[x - jp[dj]][y] == ' ') { 143 
144                 mmp[x][y] = ' '; 145                 x -= jp[dj]; 146                 mmp[x][y] = 'O'; 147 
148                 dj--; 149 
150             } else { 151 
152                 dj = 0; 153 
154  } 155 
156         } else { 157 
158             if (x == 9) { 159 
160                 mmp[x][y] = ' '; 161                 x = 8, y = 0; 162                 mmp[x][y] = 'O'; 163                 y--; 164 
165             } else { 166 
167                 if (mmp[x + 1][y] == ' ') { 168 
169                     if (tick % 2 == 0) { 170 
171                         mmp[x][y] = ' '; 172                         x++; 173                         mmp[x][y] = 'O'; 174 
175  } 176 
177  } 178 
179  } 180 
181  } 182 
183         mmp[x][y] = ' '; 184         y++; 185         if (mmp[x][y] == '#') { 186 
187             y--; 188 
189  } 190         if (y == 100) { 191 
192             y = 0; 193 
194             for (register int i = 0; i < 10; i++) { 195 
196                 putmmp[i][15] = ' '; 197 
198  } 199 
200  } 201         mmp[x][y] = 'O'; 202         tick++; 203 
204  } 205 
206     return 0; 207 
208 }

 

轉載請註明©Ice_watermelon233code

相關文章
相關標籤/搜索