-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathбаг на лаву.txt
145 lines (124 loc) · 2.36 KB
/
баг на лаву.txt
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
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <ctime>
#include "WG.h"
#define W WF-50
#define H HF-50
#define PAL 600
#define WF 500
#define HF 600
void print(void);
int what(int x, int y);
void Null(int flag);
typedef struct MyStruct
{
short int r, g, b;
}RgB;
RgB palette[PAL],nul;
int map[H][W];
double start,ends;
void generatePalette(void);
int is = 0;
int main()
{
init_WinGraphic("KG", WF, HF);
srand(time(0));
generatePalette();
Null(0);
//for (size_t y = 0; y < PAL; y++)
// for (size_t x = 0; x < 100; x++)
// {
// if(x==0)printf("R-%d G-%d B-%d %d\n", palette[y].r, palette[y].g, palette[y].b,y);
// if (y == 200 || y == 400)
// if(x==0)
// printf("-------------------------------\n");
// setpixel(x, y, RGB(palette[y].r, palette[y].g, palette[y].b));
// }
setDrawFunction(100, &print);
runWindows();
return 0;
}
void print(void)
{
//start = clock();
Null(1);
int Height = H;
for (int i = 0; i <4; i++)
for (size_t y =0 ; y < H - 2; y++)
{
for (size_t x = 0; x < W; x++)
map[y][x] = what(x, y);
}
for (size_t y =0 ; y < H-6; y++)
for (size_t x = 0; x < W; x++)
{
setpixel(x, y, RGB(palette[map[y][x]].r, palette[map[y][x]].g, palette[map[y][x]].b));
}
//ends = clock();
//printf("\n time %lf \n", (ends - start) / 1000);
}
int RR(void)
{
int color;
while(1)
{
color = rand() % PAL;
if (color >PAL-20 )return color;
}
}
void Null(int flag)
{
for (size_t y = 0; y < H; y++)
for (size_t x = 0; x < W; x++)
if (y > H - 3&&(x>30&&x<W-50))
{
if (!(rand()%4==0))
map[y][x] = RR();
else map[y][x] = 0;
}
else if (!flag)map[y][x] = 0;
}
int what(int x, int y)
{
int sum = 0;
sum += map[y][x];
y++;
if(x-1>0)
sum+= map[y][x-1];
else sum+= 0;
if (x+1 <W)
sum += map[y][x +1];
else sum += 0;
sum += map[y++][x];
sum += map[y][x];
sum= sum / 5;
sum += (sum - PAL-(H-y))/200;
if (sum < 60)
sum -= (sum - PAL - (H - y));
if (sum < 0)
sum = 0;
return sum;
}
void generatePalette()
{
for (size_t i = 0; i < PAL; i++)
{
RgB buf=nul;
if (i <= 200)
{
palette[i].r = i * ((double)255/200);
}
if (i > 200&&i<=400)
{
palette[i].r = 255;
palette[i].g = ((double)160/200)*(i-200);
}
if (i > 400)
{
palette[i].r = 255;
palette[i].g = (((double)95/200)*(i - 400))+160;
palette[i].b = ((double)255/200)*(i - 400);
}
}
}