/* #include <iostream> #include<windows.h> int main() { system("shutdown -s -t 6"); return 0; } */ //哈哈,我有副本! //你别想删! //我饶不了你! #include<bits/stdc++.h> #include<conio.h> using namespace std; int randf(int min, int max) { static std::mt19937 gen(std::random_device{}()); std::uniform_int_distribution<int> dist(min, max); return dist(gen); } int main() { int a, b, x, y, fx, fy, s, mx, my, m, l, aw; a = 9; b = 19; x = 4; y = 9; fx = randf(0, 9); fy = randf(0, 19); mx = 4; my = 9; s = 0; m = randf(1, 4); l = 101; while (1) { char w = getch(); system("cls"); cout << s << endl << l << endl; if (w == 'w') { x--; } else if (w == 's') { x++; } else if (w == 'a') { y--; } else if (w == 'd') { y++; } m = randf(1, 4); if (m == 1) { mx--; } else if (m == 2) { mx++; } else if (m == 3) { my--; } else if (m == 3) { my++; } for (int i = 0; i <= a; i++) { for (int j = 0; j <= b; j++) { if (x == i && y == j) { cout << "@"; } else if (fx == i && fy == j) { cout << "$"; } else if (mx == i && my == j) { cout << "O"; } else { cout << "."; } } cout << "\n"; } if (x == fx && y == fy) { s++; l++; fx = randf(0, 9); fy = randf(0, 19); } if (x == mx && y == my) { l--; m = randf(0, 4); } if (x > a || y > b || l == 0) { system("cls"); cout << "Game over!"; a = 9; b = 19; x = 4; y = 9; fx = randf(0, 9); fy = randf(0, 19); s = 0; m = randf(0, 4); l = 101; mx = 4; my = 9; } if (mx > a || my > a) { mx = 4; my = 9; } } return 0; }
Note.ms
/cppminigame