-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
160 lines (136 loc) · 3.93 KB
/
main.c
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#define TILE_SIZE_X 3
#define TILE_SIZE_Y 3
#define TILE_WIDTH 60
#define TILE_HEIGHT 21
#define PIXEL_BLOCK "█"
#define PIXEL_HALFB "▄"
#define PIXEL_HALFT "▀"
#define SPACE "░"
typedef struct texture_map {
char * buffer[TILE_SIZE_X][TILE_SIZE_Y];
} texture;
/* char* (*texture_map[3][3])[10]; */
texture * texture_map[10];
char* pixel_buffer[TILE_WIDTH * TILE_SIZE_X][TILE_HEIGHT * TILE_SIZE_Y];
void one_to_nine_character(int index, int x, int y) {
x = x * 3 + 1;
y = y * 3 + 1;
for (int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
/* pixel_buffer[x + i][y + j] = (*texture_map[index])[i + 1][j + 1]; */
pixel_buffer[x + i][y + j] = texture_map[index]->buffer[j + 1][i + 1];
}
}
}
void draw_final_console() {
/* for (int i = 0; i < TILE_WIDTH * TILE_SIZE_X; i++) {
for (int j = 0; j < TILE_HEIGHT * TILE_SIZE_Y; j++) {
if (pixel_buffer[i][j] == NULL) {
printf("_");
continue;
}
printf("%s", (pixel_buffer[i][j]));
}
printf("\n");
} */
for (int y = 0; y < TILE_HEIGHT * TILE_SIZE_Y; y++)
{
for (int x = 0; x < TILE_WIDTH * TILE_SIZE_X; x++)
{
if (pixel_buffer[x][y] == NULL) {
printf("_");
continue;
}
printf("%s", (pixel_buffer[x][y]));
}
printf("\n");
}
}
void set_big_buff() {
for (int x = 0; x < (TILE_WIDTH); x++) {
for (int y = 0; y < TILE_HEIGHT; y++) {
/* if (i == 0) one_to_nine_character(1, i, j);
else {
one_to_nine_character(0, i, j);
} */
/* one_to_nine_character(i % 2 , i, j); */
int is_wall = 0;
if (y == 0 || y == TILE_HEIGHT - 1) {
is_wall = 1;
} else if (x == 0 || x == TILE_WIDTH - 1) {
is_wall = 1;
}
one_to_nine_character(is_wall , x, y);
/* if (i == 0 || i == TILE_WIDTH - 1) {
} */
}
}
}
int main() {
texture texture_first = {
.buffer = {
{PIXEL_HALFB, PIXEL_BLOCK, PIXEL_HALFB},
{PIXEL_BLOCK,PIXEL_BLOCK,PIXEL_BLOCK},
{PIXEL_HALFT, PIXEL_BLOCK, PIXEL_HALFT},
}
};
texture texture_second = {
.buffer = {
{PIXEL_BLOCK, PIXEL_HALFT, PIXEL_BLOCK},
{PIXEL_BLOCK, SPACE, PIXEL_BLOCK},
{PIXEL_BLOCK, PIXEL_HALFB, PIXEL_BLOCK}
}
};
texture texture_space = {
.buffer = {
{SPACE, SPACE, SPACE},
{SPACE,SPACE,SPACE},
{SPACE, SPACE, SPACE},
}
};
texture blank = {
.buffer = {
{"1", "2", "3"},
{"4", "5", "6"},
{"7", "8", "9"}
}
};
texture_map[0] = &texture_space;
texture_map[1] = &texture_second;
set_big_buff();
draw_final_console();
return 0;
}
/* texture_map[1] = &texture2; */
// for (int i = 0; i < 1; i++)
// {
// for (int j = 0; j < 3; j++)
// {
// for (int k = 0; k < 3; k++)
// {
// printf("%s", (*texture_map[i])[j][k]);
// }
// printf("\n");
// }
// printf("========\n");
// }
/* char texture2[TILE_SIZE_X][TILE_SIZE_Y] = {
{'y', 'y', 'y'},
{'y', "x", "x"},
{'y', 'y', 'y'},
}; */
/* char* pixel_buffer[TILE_WIDTH * TILE_SIZE_X][TILE_HEIGHT * TILE_SIZE_Y];
int tile_map[TILE_WIDTH][TILE_HEIGHT]; */
/* char* texture_map[10]; */
//long long current_timestamp() {
// struct timeval te;
// gettimeofday(&te, NULL); // get current time
// long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds
// // printf("milliseconds: %lld\n", milliseconds);
// return milliseconds;
//}