MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / Map

Function Map

Project_Snake_Game/snake-game.cpp:51–94  ·  view source on GitHub ↗

Creating a map container where snake and fruit appears

Source from the content-addressed store, hash-verified

49
50//Creating a map container where snake and fruit appears
51void Map() {
52 system("cls");
53 SetConsoleTextAttribute(hConsole, 180);
54 for (int i = 0; i < width + 2; i++)
55 cout << "#";
56 cout << endl;
57
58 for (int i = 0; i < height; i++)
59 {
60 for (int j = 0; j < width; j++)
61 {
62 if (j == 0)
63 cout << "#";
64 if (i == y && j == x)
65 cout << "O";
66 else if (i == fy && j == fx)
67 cout << "X";
68 else
69 {
70 bool print = false;
71 for (int k = 0; k < nt; k++) {
72 if (tx[k] == j && ty[k] == i)
73 {
74 cout << "o";
75 print = true;
76 }
77
78 }
79 if (!print)
80 cout << " ";
81 }
82
83 if (j == width - 1)
84 cout << "#";
85 }
86 cout << endl;
87 }
88
89 for (int i = 0; i < width + 2; i++)
90 cout << "#";
91 cout << endl;
92 cout << "Score is " << score << endl;
93
94}
95// managing input of keyboard to control snake
96void Input() {
97 if (_kbhit())

Callers 1

startGameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected