解决了闪屏的BUG
可以在任意Windows系统上编译
可以在任意c++编译器上编译
分数固定在了底下
修了很多小BUG
球和挡板的移动速度会慢慢变快
方向键也可以控制挡板
添加了很多细节
#include#include #include #include #include #include using namespace std; string q = "o", db = "-----", kk[31] = { "", " |---------------------------------------------------------------------------------------------------|", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " | |", " |---------------------------------------------------------------------------------------------------|" }; long long x, y, dx, dy, hb = 95, fs = 0, y_x, y_y, y_hb; long double sd; bool f = 1; void csh();//初始化 void in();//输入 void out();//输出 void qgx();//球坐标的更新 void pd();//判断结束 void gx();//更新 void color(int c) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c); return; } void gb() { CONSOLE_CURSOR_INFO cursor; cursor.bVisible = FALSE; cursor.dwSize = sizeof(cursor); HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorInfo(handle, &cursor); return; } void ydgb(long long x, long long y) { COORD pos = { y,x }; HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOut, pos); return; } int main() { gb(); color(11); csh(); out(); for (long long i = 1; f; i++) { in(); if (i % 5 == 0) { qgx(); if (sd > 6) sd -= 0.2; } pd(); Sleep(long(sd)); gx(); if (i == 1) { system("cls"); out(); } } color(11); system("cls"); printf("你得了%d分n按空格退出", fs); char t = _getch(); while (t != ' ')t = _getch(); return 0; } void csh() { system("mode con cols=102 lines=31"); srand(time(0)); x = 4; y = rand() % 99 + 2; dx = 1; dy = 1; y_x = x, y_y = y; sd = 70; return; } void in() { if (GetKeyState('A') < 0 || GetKeyState(37) < 0) { if (hb > 2) { hb -= 1; } } if (GetKeyState('D') < 0 || GetKeyState(39) < 0) { if (hb < 99 - 4) { hb += 1; } } return; } void out() { system("cls"); for (long long i = 1; i <= 30; i++) { for (long long j = 1; j <= 101; j++) { color(11); cout << kk[i][j]; } if (i != 30) cout << "n"; } return; } void qgx() { if (x == 3 || (x == 28 && (hb == y || y + dy == hb + 1 || y + dy == hb + 2 || y + dy == hb + 3 || y + dy == hb + 4 || y == hb + 5)))dx *= -1; if (y == 2 || y == 100)dy *= -1; x += dx; y += dy; if (x == 28 && (hb == y || y == hb + 1 || y == hb + 2 || y == hb + 3 || y == hb + 4 || y == hb + 5))fs++; return; } void pd() { if (x == 31) f = 0; return; } void gx() { ydgb(y_x - 2, y_y); cout << "b" << " "; ydgb(x - 2, y); color(10); cout << "b" << "o"; color(14); ydgb(27, y_hb + 5); for (long long i = 1; i <= 6; i++) cout << "b"; cout << " "; ydgb(27, hb + 5); for (long long i = 1; i <= 6; i++) cout << "b"; cout << "------"; y_x = x, y_y = y; y_hb = hb; ydgb(30, 1); cout << "分数:" << fs; return; }



