Graphics

closed account (oy721hU5)
Hello dear programmers,

I am using the <windows.h> library in C with Code::Blocks 10.05 to draw small Boxes with ASCII extended characters. I am making use of a header file so that the caller program is nice and small. I created a small box with over 80 lines. Is there a way to iterate so that that box previously drawn will be shown 7 times on the screen.
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  // HEADER file
void SetCursorPosition(int x, int y)
{
	COORD XY = {y, x};
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), XY);
}
void Colors(int TxtColor)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), TxtColor);
}
void ClearScreen()
{
	system("cls");
}
void PauseScreen(int x)
{
	Colors(100);
	SetCursorPosition(x, 27);
	system("pause");
}

void StandardBox()
{
    SetCursorPosition(13, 4);
    char  Vertical[2];  // vertical line
    char VerticalT[2];  // Vertical T shaped -|
    char  TRCorner[2];
    char  BLCorner[2];
    char     UDTee[2];  // upside-down T
    char    RegTee[2];
    char VerticalI[2];  // shaped: |-
    char Horizontl[2];
    char     Kross[2];
    char BRCorner[2];  // bottom right corner
    char TLCorner[2];  // top left corner
    Vertical[0]  = 179;
    Vertical[1]  = '\0';
    VerticalT[0] = 180;
    VerticalT[1] = '\0';
    TRCorner[0]  = 191;
    TRCorner[1]  = '\0';
    BLCorner[0]  = 192;
    BLCorner[1]  = '\0';
    UDTee[0]     = 193;
    UDTee[1]     = '\0';
    RegTee[0]    = 194;
    RegTee[1]    = '\0';
    VerticalI[0] = 195;
    VerticalI[1] = '\0';
    Horizontl[0] = 196;
    Horizontl[1] = '\0';
    Kross[0]     = 197;
    Kross[1]     = '\0';
    BRCorner[0]  = 217;
    BRCorner[1]  = '\0';
    TLCorner[0]  = 218;
    TLCorner[1]  = '\0';
    // making the box
    SetCursorPosition(13, 4);
    printf(TLCorner);
    SetCursorPosition(13,5);
    printf(Horizontl);
    SetCursorPosition(13,6);
    printf(Horizontl);
    SetCursorPosition(13,7);
    printf(RegTee);
    SetCursorPosition(14,7);
    printf(Vertical);
    SetCursorPosition(14,4);
    printf(Vertical);
    SetCursorPosition(15,7);
    printf(Vertical);
    SetCursorPosition(16,7);
    printf(Vertical);
    SetCursorPosition(13,8);
    printf(Horizontl);
    SetCursorPosition(13,9);
    printf(Horizontl);
    SetCursorPosition(13,10);
    printf(TRCorner);

    SetCursorPosition(15,4);
    printf(Vertical);
    SetCursorPosition(16,4);
    printf(Vertical);
    SetCursorPosition(17,4);
    printf(VerticalI);
    SetCursorPosition(17,5);
    printf(Horizontl);
    SetCursorPosition(17,6);
    printf(Horizontl);
    SetCursorPosition(17,7);
    printf(Kross);
    SetCursorPosition(18,7);
    printf(Vertical);
    SetCursorPosition(19,7);
    printf(Vertical);
    SetCursorPosition(20,7);
    printf(Vertical);

    SetCursorPosition(17,8);
    printf(Horizontl);
    SetCursorPosition(17,9);
    printf(Horizontl);
    SetCursorPosition(17,10);
    printf(VerticalT);
    SetCursorPosition(14,10);
    printf(Vertical);
    SetCursorPosition(15,10);
    printf(Vertical);
    SetCursorPosition(16,10);
    printf(Vertical);
    SetCursorPosition(18,4);
    printf(Vertical);
    SetCursorPosition(19,4);
    printf(Vertical);
    SetCursorPosition(20,4);
    printf(Vertical);
    SetCursorPosition(21,4);
    printf(BLCorner);
    SetCursorPosition(21,5);
    printf(Horizontl);
    SetCursorPosition(21,6);
    printf(Horizontl);
    SetCursorPosition(21,7);
    printf(UDTee);
    SetCursorPosition(21,8);
    printf(Horizontl);
    SetCursorPosition(21,9);
    printf(Horizontl);
    SetCursorPosition(21,10);
    printf(BRCorner);
    SetCursorPosition(18,10);
    printf(Vertical);
    SetCursorPosition(19,10);
    printf(Vertical);
    SetCursorPosition(20,10);
    printf(Vertical);

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// caller program

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "boxes.h"

int main()
{
    StandardBox();

    PauseScreen(50);
}
Topic archived. No new replies allowed.