Today is 520 confession festival, specially prepared for everyone LAST year I use C language to express the success of the romantic confession meteor shower project source code, send this to the girl you like, you are also afraid of 520 can not find the object, to a person?

Without saying much, directly on the effect:

Development environment: Visual Studio 2019 + EasyX graphics library plug-in

Let’s look at the source code:

#include<stdio.h>#include<math.h>#include<time.h>#include<conio.h>#include<graphics.h> #include<mmsystem.h>#pragma comment(lib,"winmm.lib") #define PI 3.1415#define NUM 13 WIDTH 960#define HEIGHT 640struct Fire{int x, y; int cen_x, cen_y; // Int r; // Current bloom radius int max_r; Int width, height; DWORD pixel[240][240]; // Array of image pixels bool isShow; Bool isDraw; // Bool isDraw; }fire[NUM]; Struct Jet // {int x, y; Int hx, hy; Bool isLaunch; // IMAGE img[2]; byte n : 1; Jet [NUM]; // Jet [NUM]; Void welcome(){McISendString (L"open./res/ little luck.mp3 ", 0, 0, 0); McISendString (L" play. /res/ luck.mp3 ", 0, 0, 0); for (int i = 0; i < 50; I++){// clear the screen cleardevice(); int x = 500 + 180 * sin(2 * PI / 60 * i); int y = 200 + 180 * cos(2 * PI / 60 * i); // Set font style settextStyle (I, 0, L" regular "); settextcolor(RGB(0, 202, 0)); setbkmode(TRANSPARENT); Outtextxy (x, y, L); Sleep(20); }_getch(); // Press any key to continue clearDevice (); Settextstyle (25, 0, L" regular "); Outtextxy (350, 100, L" dear XXX"); Outtextxy (350, 150, L" Since the First Day I Saw You "); Outtextxy (350, 200, L" I can't help myself "); Outtextxy (350, 250, L" Want to see you anywhere "); outtextxy(350, 300, L"..." ); outtextxy(350, 350, L"..." ); Outtextxy (450, 400, L"-- love your XXX"); }void InitData(int i); Void loadImg(){// initialize the bloom effect IMAGE bloomImg,tImg; loadimage(&bloomImg, L"./res/flower.jpg", 3120, 240); for (int i = 0; i < NUM; i++){InitData(i); SetWorkingImage(&bloomImg); getimage(&tImg, i * 240, 0, 240, 240); SetWorkingImage(&tImg); for (int a = 0; a < 240; a++){for (int b = 0; b < 240; b++){fire[i].pixel[a][b] = getpixel(a, b); }}}// Initialize the shell IMAGE jetImg; loadimage(&jetImg, L"./res/launch.jpg", 200, 50); SetWorkingImage(&jetImg); for (int i = 0; i < NUM; i++){int n = rand() % 5; getimage(&jet[i].img[0], n*20, 0, 20, 50); getimage(&jet[i].img[1], n*20 + 100, 0, 20, 50); jet[i].isLaunch = false; }SetWorkingImage(); }void InitData(int i){fire[i].cen_x = 120; fire[i].cen_y = 120; fire[i].max_r = 120; fire[i].r = 0; fire[i].width = 240; fire[i].height = 240; fire[i].isDraw = false; fire[i].isShow = false; } void createJet(){int I = rand() % NUM; //[0~13)if (jet[i].isLaunch == false){jet[i].x = rand() % (WIDTH-20);jet[i].y = rand() % 100 + HEIGHT;jet[i].hx = Jet [I].x;jet[I].hy = rand() % (HEIGHT / 3 * 2);jet[I].islaunch = true;}} void launch(){for (int I = 0; I < NUM; i++){if (jet[i].isLaunch){putimage(jet[i].x, jet[i].y, & jet [I]. Img [jet [I] n], SRCINVERT); / / to judge whether the peak if (jet [I] y > jet [I] hy) {jet [I] y - = 5; jet [I] n++;} putimage (jet [I]. X. jet[i].y, &jet[i].img[jet[i].n], SRCINVERT); the if (jet [I] y < = jet [I] hy) {jet [I] isLaunch = false; / / to start a fireworks fire [I] x = jet [I] x; the fire [I] y = jet[i].y;fire[i].isShow = true;}}}}void bloom(DWORD *pMem){for (int i = 0; i < NUM; i++){if (fire[i].isShow){if (the fire [I] r < the fire [I] max_r) {the fire [I] r++; the fire [I] isDraw = true; / / can begin to draw the fireworks} the if (the fire [I] r > = The fire [I] max_r) {InitData (I);}} the if (the fire [I] isDraw) {/ / for the current radius, For (double a = 0; a <= 2 * PI; a += 0.01){int img_x = fire[I].cen_x + fire[I].r * cos(a) img_y = fire[i].cen_y + fire[i].r * sin(a);if (img_x > 0 && img_x < fire[i].width && img_y>0 && img_y < Fire [I].height){// Int win_x= fire[I].x + fire[I].r * cos(a);int win_y = fire[I].y + fire[I].r * sin(a);if (win_x > 0 && win_x < WIDTH && win_y>0 && win_y < WIDTH){pMem[win_y * WIDTH + win_x] = BGR(fire[i].pixel[img_x][img_y]);}}}}}}int Main (){// create window initGraph (960, Srand ((unsigned)time(NULL)+clock());welcome();loadImg();DWORD* pMem = GetImageBuffer(); // Get the window memory pointer while (1){for (int i = 0; i < WIDTH; i++){for (int k = 0; k < 4; k++){int x = rand() % WIDTH;int y = rand() % HEIGHT;if (y < HEIGHT){pMem[y * WIDTH + x] = BLACK;}}}createJet();launch();bloom(pMem);Sleep(10);}closegraph();return 0;}Copy the code

Above is our confession program source code! Finally, I wish everyone can be together with their favorite people

** For learning programming partners or in the work of programmers who want to be promoted, if you want to better improve your programming ability to help you improve the level! ** I may be able to help you ~

C language C++ programming learning communication circle, **QQ group [765803539] ** wechat public Number: C language programming learning Base

Share (source code, project actual video, project notes, basic introduction tutorial)

Welcome to change and learn programming partners, use more information to learn to grow faster than their own oh!

Programming Video sharing: