Repository navigation
Expand file tree
/
Copy pathc_visual.cpp
More file actions
86 lines (63 loc) · 1.4 KB
/
Copy pathc_visual.cpp
File metadata and controls
86 lines (63 loc) · 1.4 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <ncurses.h>
#include <unistd.h>
int height = 10;
int width = 20;
int size;
int start_y = 1; int start_x = 6;
//int max_x, max_y;
//**************FUNCTION TO DRAW BOB*******************//
int c_visual(int max_x, int max_y) {
noecho();
WINDOW * c_screen = newwin(height, width, start_y, (max_x/3)+2);
refresh();
wrefresh(c_screen);
//width = columns, height = rows
int pos; //current position in the image
int eye1 = 5*width+8;
int eye2 = 5*width+10;
int mouth = 5*width + 9;
size = height * width;
char bob[size];
//PREPARE BOB
for (int i=0; i <size; i++) {
bob[i] = ' ';
}
for (int x=0; x < width; x++) {
for(int y=0; y < height; y ++) {
pos = y*width + x;
if(y == 3 || y == 6) {
if (x >= 6 && x <= 12) {
bob[pos] = '=';
}
}
else if(y == 4 | y == 5) {
if ( x == 5 | x == 13) {
bob[pos] = '|';
}
}
}
}
bob[eye1] = 'O';
bob[eye2] = 'O';
bob[mouth] = 'w';
//PRINT BOB
start_color();
init_pair(1, COLOR_BLUE, COLOR_BLACK);
for(int x=0; x < width; x++) {
for(int y=0; y < height; y++) {
pos = y*width + x;
if (pos > 65 && pos < 73 ||
pos > 84 && pos < 94 ||
pos > 104 && pos < 114 ||
pos > 125 && pos < 133){
wattron(c_screen, COLOR_PAIR(1));
}
mvwaddch(c_screen, y, x, bob[pos]);
wattroff(c_screen, COLOR_PAIR(1));
}
}
box(c_screen, 0, 0);
wrefresh(c_screen);
//getch();
return 0;
}