-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDisplay.cpp
41 lines (34 loc) · 972 Bytes
/
Display.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Display.h"
#include <stdio.h>
static int display[DISPLAY_HEIGHT][DISPLAY_WIDTH];
int Display_clearArena() {
for (int row = 0; row < DISPLAY_HEIGHT; ++row) {
for (int column = 0; column < DISPLAY_WIDTH; ++column) {
if (column == 0 || column == DISPLAY_WIDTH - 1 || row == 0 ||
row == DISPLAY_HEIGHT - 1) {
display[row][column] = '#';
} else {
display[row][column] = ' ';
}
}
}
return 1;
}
int Display_drawScreen() {
for (int row = 0; row < DISPLAY_HEIGHT; ++row) {
for (int column = 0; column < DISPLAY_WIDTH; ++column) {
printf("%c", display[row][column]);
}
printf("\n");
}
return 1;
}
int Display_drawSnakeSection(int x, int y, int section) {
if (section == 0) {
// we're drawing the head
display[x][y] = '0';
} else {
display[x][y] = 'x';
}
return 1;
}