赞
踩
- #include<stdio.h>
- #include<Windows.h>
- #include<graphics.h>
- #include<conio.h>
- #include<time.h>
-
-
- void init_window();
-
- void hua_rain(int n);
-
- void down_rain();
-
- void date_windows();
-
- void init_rain();
-
- #define rain_num 100
- #define WIN_HEIGHT 640
- #define WIN_WIDTH 1080
-
- typedef struct Rain
- {
- int x;
- int y;
- }rain;
-
- rain rains[rain_num];
-
- void init_window()
- {
- system("title 黑客帝国-代码雨");
- initgraph(WIN_WIDTH, WIN_HEIGHT);
- }
-
-
- void init_rain()
- {
- for (int i = 0; i < rain_num; i++)
- {
- rains[i].x = rand() % WIN_WIDTH;
- rains[i].y = rand() % WIN_HEIGHT;
- }
- }
-
- void hua_rain(int n)
- {
- for (int i = 0; i < n; i++)
- {
- settextcolor(RGB(0, 255, 0));
- outtextxy(rains[n].x, rains[n].y, rand() % 2 + 48);
- }
- }
- void down_rain()
- {
- for (int i = 0; i < rain_num; i++)
- {
- hua_rain(i);
- rains[i].y += 25;
- rains[i].x += 1;
- if (rains[i].y > WIN_HEIGHT)
- {
- rains[i].x = rand() % WIN_WIDTH;
- rains[i].y = rand() % 50;
- }
- }
- }
void date_windows() { BeginBatchDraw(); DWORD t1, t2; t1 = GetTickCount64(); while (1) { t2 = GetTickCount64(); if (t2 - t1 > 20) { cleardevice(); down_rain(); EndBatchDraw(); t1 = t2; } } }
-
- int main()
- {
- srand(time(NULL));
- init_window();
- init_rain();
- date_windows();
- return 0;
- }
#include<stdio.h> #include<Windows.h> #include<graphics.h> #include<conio.h> #include<time.h> #define rain_num 100 #define WIN_HEIGHT 640 #define WIN_WIDTH 1080 typedef struct Rain { int x; int y; }rain; rain rains[rain_num]; void hua_rain(int n) { for (int i = 0; i < n; i++) { settextcolor(RGB(0, 255, 0)); outtextxy(rains[n].x, rains[n].y, rand() % 2 + 48); } } void init_window() { system("title 黑客帝国-代码雨"); initgraph(WIN_WIDTH, WIN_HEIGHT); } void down_rain() { for (int i = 0; i < rain_num; i++) { hua_rain(i); rains[i].y += 25; rains[i].x += 1; if (rains[i].y > WIN_HEIGHT) { rains[i].x = rand() % WIN_WIDTH; rains[i].y = rand() % 50; } } } void date_windows() { BeginBatchDraw(); DWORD t1, t2; t1 = GetTickCount64(); while (1) { t2 = GetTickCount64(); if (t2 - t1 > 20) { cleardevice(); down_rain(); EndBatchDraw(); t1 = t2; } } } void init_rain() { for (int i = 0; i < rain_num; i++) { rains[i].x = rand() % WIN_WIDTH; rains[i].y = rand() % WIN_HEIGHT; } } int main() { srand(time(NULL)); init_window(); init_rain(); date_windows(); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。