Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Глобальные для фона
- // то что менять НЕЛЬЗЯ
- int map_size_x = 320; // длина по х одного куска
- int map_size_y = 25; // ширина по у одного куска
- //то что менять можно, но уже нельзя
- int x_gor = 565; // уровень линии горизонта ОРИГИНАЛ 500
- int map_cx[4] = { 0, 320, 640,960};// координаты по x
- int map_cy = 65; // координаты по у ОРИГИНАЛ 0
- //массив карандашей для фона
- #define N_hPen_map 6
- HPEN hPen_map[N_hPen_map] = {
- CreatePen(PS_SOLID, 2, RGB(61, 18, 60)), //кисть для гор
- CreatePen(PS_SOLID, 2, RGB(89,18,60)),// для холмов
- CreatePen(PS_SOLID, 2, RGB(116, 35, 94)), //для земли
- CreatePen(PS_SOLID, 2, RGB(255, 255, 255)),
- CreatePen(PS_SOLID, 2, RGB(128,0,0)),
- CreatePen(PS_SOLID, 4, RGB(64,0,0))
- };
- // массив кистей для фона
- #define N_MapBr 5
- HBRUSH hbrush_map[N_MapBr] = {
- CreateSolidBrush(RGB(61, 18, 60)),//кисть для гор
- CreateSolidBrush(RGB(89,18,60)),//для холмлв
- CreateSolidBrush(RGB(116,35,94)),//для земли
- CreateSolidBrush(RGB(128,38,98)),
- CreateSolidBrush(RGB(128,0,0))
- };
- ////////// НАЧАЛО ФОНА
- void stars(HDC hdc, int n) {
- SetPixel(hdc, map_cx[n] + 43, map_cy + 14, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 25, map_cy + 89, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 12, map_cy + 189, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 64, map_cy + 161, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 128, map_cy + 32, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 250, map_cy + 132, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 190, map_cy + 196, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 310, map_cy + 45, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 165, map_cy + 100, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 227, map_cy + 19, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 284, map_cy + 175, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 131, map_cy + 225, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 90, map_cy + 90, RGB(255, 255, 255));
- SetPixel(hdc, map_cx[n] + 170, map_cy + 259, RGB(255, 255, 255));
- }
- //СОЗДАЕМ ГРАДИЕНТНУЮ КИСТЬ ДЛЯ НЕБА - слой 1-4
- void HBRUSH_SKY_1(HDC hdc) {
- int x = 50;
- int y = 0;
- int z = 150;
- int i = 0;
- int cx = map_cx[0];
- int cy = map_cy;
- while (i < 18) {
- HBRUSH hBrush = CreateSolidBrush(RGB(x, y, z));
- SelectObject(hdc, hBrush);
- HPEN hpen = CreatePen(PS_SOLID, 2, RGB(x, y, z));
- SelectObject(hdc, hpen);
- Rectangle(hdc, cx, cy, cx + map_size_x, cy + map_size_y);
- DeleteObject(hBrush);
- DeleteObject(hpen);
- cx = map_cx[0];
- cy += map_size_y;
- i++;
- x+=5;
- y++;
- z+=3;
- }
- }
- void HBRUSH_SKY_2(HDC hdc) {
- int x = 50;
- int y = 0;
- int z = 150;
- int i = 0;
- int cx = map_cx[1];
- int cy = map_cy;
- while (i < 18) {
- HBRUSH hBrush = CreateSolidBrush(RGB(x, y, z));
- SelectObject(hdc, hBrush);
- HPEN hpen = CreatePen(PS_SOLID, 2, RGB(x, y, z));
- SelectObject(hdc, hpen);
- Rectangle(hdc, cx, cy, cx + map_size_x, cy + map_size_y);
- DeleteObject(hBrush);
- DeleteObject(hpen);
- cx = map_cx[1];
- cy += map_size_y;
- i++;
- x += 5;
- y++;
- z += 3;
- }
- }
- void HBRUSH_SKY_3(HDC hdc) {
- int x = 50;
- int y = 0;
- int z = 150;
- int i = 0;
- int cx = map_cx[2];
- int cy = map_cy;
- while (i < 18) {
- HBRUSH hBrush = CreateSolidBrush(RGB(x, y, z));
- SelectObject(hdc, hBrush);
- HPEN hpen = CreatePen(PS_SOLID, 2, RGB(x, y, z));
- SelectObject(hdc, hpen);
- Rectangle(hdc, cx, cy, cx + map_size_x, cy + map_size_y);
- DeleteObject(hBrush);
- DeleteObject(hpen);
- cx = map_cx[2];
- cy += map_size_y;
- i++;
- x += 5;
- y++;
- z += 3;
- }
- }
- void HBRUSH_SKY_4(HDC hdc) {
- int x = 50;
- int y = 0;
- int z = 150;
- int i = 0;
- int cx = map_cx[3];
- int cy = map_cy;
- while (i < 18) {
- HBRUSH hBrush = CreateSolidBrush(RGB(x, y, z));
- SelectObject(hdc, hBrush);
- HPEN hpen = CreatePen(PS_SOLID, 2, RGB(x, y, z));
- SelectObject(hdc, hpen);
- Rectangle(hdc, cx, cy, cx + map_size_x, cy + map_size_y);
- DeleteObject(hBrush);
- DeleteObject(hpen);
- cx = map_cx[3];
- cy += map_size_y;
- i++;
- x += 5;
- y++;
- z += 3;
- }
- }
- // СЛОЙ 2 - горы вдали, куски 1-4
- void decorate_1_mountain(HDC hdc) {
- POINT pt[14] = {
- {map_cx[0], map_cy + 260},
- {map_cx[0] + 40, map_cy + 300},
- {map_cx[0] + 82, map_cy + 220},
- {map_cx[0] + 105, map_cy + 275},
- {map_cx[0] + 115, map_cy + 260},
- {map_cx[0] + 160, map_cy + 320},
- {map_cx[0] + 180 , map_cy + 290 },
- {map_cx[0] + 195, map_cy + 271 },
- {map_cx[0] + 220, map_cy + 256 },
- {map_cx[0] + 240, map_cy + 278 },
- {map_cx[0] + 280, map_cy + 200 },
- {map_cx[0] + map_size_x , map_cy + 250 },
- {map_cx[0] + map_size_x , map_cy + x_gor},
- {map_cx[0] , map_cy + x_gor}
- };
- SelectObject(hdc, hPen_map[0]);
- SelectObject(hdc, hbrush_map[0]);
- Polygon(hdc, pt, 14);
- stars(hdc, 0);
- }
- void decorate_2_mountain(HDC hdc) {
- POINT pt[15] = {
- {map_cx[1], map_cy + 250},
- {map_cx[1] + 20, map_cy + 240},
- {map_cx[1] + 47, map_cy + 255},
- {map_cx[1] + 62, map_cy + 210},
- {map_cx[1] + 100, map_cy + 250},
- {map_cx[1] + 115, map_cy + 270},
- {map_cx[1] + 160, map_cy + 290},
- {map_cx[1] + 180 , map_cy + 260 },
- {map_cx[1] + 195, map_cy + 241 },
- {map_cx[1] + 220, map_cy + 266 },
- {map_cx[1] + 240, map_cy + 278 },
- {map_cx[1] + 280, map_cy + 200 },
- {map_cx[1] + map_size_x , map_cy + 250 },
- {map_cx[1] + map_size_x , map_cy + x_gor},
- {map_cx[1] , map_cy + x_gor}
- };
- SelectObject(hdc, hPen_map[0]);
- SelectObject(hdc, hbrush_map[0]);
- Polygon(hdc, pt, 15);
- stars(hdc, 1);
- }
- void decorate_3_mountain(HDC hdc) {
- POINT pt[11] = {
- {map_cx[2], map_cy + 250},
- {map_cx[2] + 80, map_cy + 320},
- {map_cx[2] + 100, map_cy + 290 },
- {map_cx[2] + 120, map_cy + 305},
- {map_cx[2] + 160, map_cy + 270 },
- {map_cx[2] + 195 , map_cy + 300},
- {map_cx[2] + 230 , map_cy + 255},
- {map_cx[2] + 260, map_cy + 270 },
- {map_cx[2] + map_size_x, map_cy + 230 },
- {map_cx[2] + map_size_x , map_cy + x_gor },
- {map_cx[2] , map_cy + x_gor }
- };
- SelectObject(hdc, hPen_map[0]);
- SelectObject(hdc, hbrush_map[0]);
- Polygon(hdc, pt, 11);
- stars(hdc, 2);
- }
- void decorate_4_mountain(HDC hdc) {
- POINT pt[13] = {
- {map_cx[3], map_cy + 230},
- {map_cx[3] + 68, map_cy + 285},
- {map_cx[3] + 96, map_cy + 270 },
- {map_cx[3] + 110, map_cy + 300},
- {map_cx[3] + 125, map_cy + 290 },
- {map_cx[3] + 170 , map_cy + 340},
- {map_cx[3] + 185 , map_cy + 325},
- {map_cx[3] + 195, map_cy + 333 },
- {map_cx[3] + 250, map_cy + 283},
- {map_cx[3] + 270, map_cy + 310 },
- {map_cx[3] + map_size_x -1, map_cy + 260 },
- {map_cx[3] + map_size_x -1, map_cy + x_gor},
- {map_cx[3] , map_cy + x_gor}
- };
- SelectObject(hdc, hPen_map[0]);
- SelectObject(hdc, hbrush_map[0]);
- Polygon(hdc, pt, 13);
- stars(hdc, 3);
- }
- // СЛОЙ 3 равнины + деревья
- /// Деревья
- void Tree(HDC hdc, int x, int y, int size) {
- SelectObject(hdc, hbrush_map[4]);
- SelectObject(hdc, hPen_map[4]);
- Ellipse(hdc, x, y, x + size, y + size);
- Ellipse(hdc, x, y, x - size, y + size);
- Ellipse(hdc, x - 0.5 * size, y - 0.7 * size, x + 0.5 * size, y + 0.3 * size);
- SelectObject(hdc, hPen_map[5]);
- MoveToEx(hdc, x, y + 0.4*size, NULL);
- LineTo(hdc, x, y + 2 * size);
- MoveToEx(hdc, x, y, NULL);
- }
- void Fild_1(HDC hdc) {
- //задний план
- POINT pt2[7] = {
- {map_cx[0], map_cy + 425},
- {map_cx[0]+ 45, map_cy + 405},
- {map_cx[0] + 140, map_cy + 440},
- {map_cx[0] + 271, map_cy + 392},
- {map_cx[0] + map_size_x, map_cy + 409},
- {map_cx[0] + map_size_x, map_cy + x_gor + 3},
- {map_cx[0], map_cy + x_gor +3}
- };
- SelectObject(hdc, hPen_map[1]);
- SelectObject(hdc, hbrush_map[1]);
- // передний план
- Polygon(hdc, pt2, 7);
- POINT pt1[6] = {
- {map_cx[0], map_cy + 433},
- {map_cx[0] +40, map_cy + 445},
- {map_cx[0] + 132, map_cy + 420},
- {map_cx[0] + map_size_x, map_cy + 465},
- {map_cx[0] + map_size_x, map_cy + x_gor + 3},
- {map_cx[0], map_cy + x_gor + 3}
- };
- SelectObject(hdc, hbrush_map[2]);
- Polygon(hdc, pt1, 6);
- SelectObject(hdc, hPen_map[2]);
- Rectangle(hdc, map_cx[0], x_gor, map_cx[0] + map_size_x, map_size_y * 7 + x_gor);
- Tree(hdc, map_cx[0] + 300, x_gor - 20 , 20);
- Tree(hdc, map_cx[0] + 170, x_gor - 70, 20);
- Tree(hdc, map_cx[0] + 145, x_gor - 50, 10);
- Tree(hdc, map_cx[0] + 60, x_gor + 80, 35);
- }
- void Fild_2(HDC hdc) {
- POINT pt2[7] = {
- {map_cx[1], map_cy + 410},
- {map_cx[1] + 50, map_cy + 420},
- {map_cx[1] + 200, map_cy + 415},
- {map_cx[1] + map_size_x, map_cy + 460},
- {map_cx[1] + map_size_x, map_cy + x_gor + 3},
- {map_cx[1] + 123, map_cy + x_gor + 3 },
- {map_cx[1], map_cy + 465}
- };
- SelectObject(hdc, hPen_map[1]);
- SelectObject(hdc, hbrush_map[1]);
- Polygon(hdc, pt2, 7);
- //продолжение переднего плана
- POINT pt1[3] = {
- { map_cx[1], map_cy + 467},
- {map_cx[1] + 310, map_cy + x_gor + 3},
- {map_cx[1] , map_cy + x_gor + 3}
- };
- SelectObject(hdc, hPen_map[2]);
- SelectObject(hdc, hbrush_map[2]);
- Polygon(hdc, pt1, 3);
- Rectangle(hdc, map_cx[1],x_gor, map_cx[1] + map_size_x, map_size_y*7 + x_gor);
- SelectObject(hdc, hPen_map[1]);
- SelectObject(hdc, hbrush_map[1]);
- MoveToEx(hdc, map_cx[1], map_cy + 466, NULL); // дорисовываем линии холмов
- LineTo(hdc, map_cx[1] + 160, map_cy + 515);
- MoveToEx(hdc, map_cx[1] + map_size_x, map_cy + 503, NULL);
- LineTo(hdc, map_cx[1] + 280, map_cy + 510);
- Tree(hdc, map_cx[1] + 148, x_gor - 21, 10);
- Tree(hdc, map_cx[1] + 160, x_gor - 10, 5);
- Tree(hdc, map_cx[1] + 130, x_gor - 15, 8);
- }
- void Fild_3(HDC hdc) {
- POINT pt2[3] = {
- {map_cx[2], map_cy + 460},
- {map_cx[2] + 220, x_gor + 30},
- {map_cx[2], map_cy + x_gor + 3}
- };
- SelectObject(hdc, hPen_map[1]);
- SelectObject(hdc, hbrush_map[1]);
- Polygon(hdc, pt2, 3);
- //передний план
- POINT pt1[3] = {
- {map_cx[2] , x_gor + 3},
- {map_cx[2] + 180, map_cy + 460},
- {map_cx[2] + map_size_x,x_gor + 3}
- };
- SelectObject(hdc, hbrush_map[2]);
- Polygon(hdc, pt1, 3);
- SelectObject(hdc, hPen_map[2]);
- Rectangle(hdc, map_cx[2], x_gor, map_cx[2] + map_size_x, map_size_y * 7 + x_gor);
- SelectObject(hdc, hPen_map[1]);
- MoveToEx(hdc, map_cx[2] + 28, + x_gor - 3, NULL); // дорисовываем линии холмов
- LineTo(hdc, map_cx[2]-1, map_cy + 503);
- MoveToEx(hdc, map_cx[2] + 300, x_gor - 3, NULL); // дорисовываем линии холмов
- LineTo(hdc, map_cx[2] + map_size_x , x_gor + 5);
- Tree(hdc, map_cx[2] + 46, x_gor - 30, 15);
- Tree(hdc, map_cx[2] + 246, x_gor -10, 17);
- Tree(hdc, map_cx[2] + 266, x_gor +5, 10);
- }
- void Fild_4(HDC hdc) {
- POINT pt2[3] = {
- {map_cx[3] , x_gor },
- {map_cx[3] + 100, map_cy + 460},
- {map_cx[3] + map_size_x, x_gor + 3}
- };
- SelectObject(hdc, hPen_map[1]);
- SelectObject(hdc, hbrush_map[1]);
- Polygon(hdc, pt2, 3);
- //передний план
- POINT pt1[3] = {
- {map_cx[3] , x_gor +20},
- {map_cx[3] + map_size_x, map_cy + 433},
- {map_cx[3] + map_size_x, x_gor + 3}
- };
- SelectObject(hdc, hbrush_map[2]);
- Polygon(hdc, pt1, 3);
- SelectObject(hdc, hPen_map[2]);
- Rectangle(hdc, map_cx[3], x_gor, map_cx[3] + map_size_x, map_size_y * 7 + x_gor);
- SelectObject(hdc, hPen_map[1]);
- MoveToEx(hdc, map_cx[3] + 86, x_gor - 3, NULL); // дорисовываем линии холмов
- LineTo(hdc, map_cx[3], map_cy + 528);
- Tree(hdc, map_cx[3] + 266, x_gor - 40 , 30);
- }
- ////////// КОНЕЦ ФОНА
- HBRUSH_SKY_1(hdc);
- decorate_1_mountain(hdc);
- Fild_1(hdc);
- HBRUSH_SKY_2(hdc);
- decorate_2_mountain(hdc);
- Fild_2(hdc);
- HBRUSH_SKY_3(hdc);
- decorate_3_mountain(hdc);
- Fild_3(hdc);
- HBRUSH_SKY_4(hdc);
- decorate_4_mountain(hdc);
- Fild_4(hdc);
Add Comment
Please, Sign In to add comment