style(game): redesign game board UI
This commit is contained in:
@@ -7,7 +7,7 @@ using namespace std;
|
||||
|
||||
bool gameOver;
|
||||
const int width = 40;
|
||||
const int height = 20;
|
||||
const int height = 40;
|
||||
int x, y, fruitX, fruitY, score;
|
||||
int tailX[100], tailY[100];
|
||||
int ntail;
|
||||
@@ -28,29 +28,31 @@ void setup() {
|
||||
|
||||
void draw() {
|
||||
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), {0,0});
|
||||
for(int i = 0; i < width + 2; i++) cout << "#";
|
||||
cout << "\n";
|
||||
cout << "┌";
|
||||
for(int i = 1; i < width + 1; i++) cout << "─";
|
||||
cout << "┐\n";
|
||||
for(int i = 0; i < height; i++) {
|
||||
for(int j = 0; j < width; j++ ) {
|
||||
if(j == 0) cout << "#";
|
||||
if(j == 0) cout << "│";
|
||||
if(i == y && j == x) cout << "O";
|
||||
else if(i == fruitY && j == fruitX) cout << "F";
|
||||
else {
|
||||
bool print = false;
|
||||
for (int k = 0; k < ntail; k++) {
|
||||
if (tailX[k] == j && tailY[k] == i) {
|
||||
cout << "o";
|
||||
cout << "@";
|
||||
print = true;
|
||||
}
|
||||
}
|
||||
if(!print) cout << " ";
|
||||
}
|
||||
if(j == width - 1) cout << "#";
|
||||
if(j == width - 1) cout << "│";
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
for(int i = 0; i < width + 2; i++) cout << "#";
|
||||
cout << "\n";
|
||||
cout << "└";
|
||||
for(int i = 1; i < width + 1; i++) cout << "─";
|
||||
cout << "┘\n";
|
||||
cout << "score:" << score << "\n";
|
||||
cout << "Time: " << timer << "s\n"; // Display timer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user