c语言烟花程序代码 -回复

c语言烟花程序代码 -回复


2024年4月15日发(作者:)

c语言烟花程序代码 -回复

下面是一个简单的 C 语言烟花程序代码:

c

include

include

include

include

void delay(int milliseconds) {

long pause;

clock_t now, then;

pause = milliseconds * (CLOCKS_PER_SEC / 1000);

now = then = clock();

while ((now - then) < pause) {

now = clock();

}

}

void setCursorPos(int x, int y) {

COORD pos = {x, y};

HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(output, pos);

}

void setColor(int color) {

HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(output, color);

}

int main() {

srand(time(NULL));

int width = 50;

int height = 20;

int x = width / 2;

int y = height - 2;

while (1) {

int r = rand() 256;

int g = rand() 256;

int b = rand() 256;

int color = r + g * 256 + b * 256 * 256;

int speed = 1 + rand() 5;

int angle = 30 + rand() 121;

int rads = angle * 3.14159 / 180;

float vx = speed * cos(rads);

float vy = -speed * sin(rads);

setCursorPos(x, y);

setColor(color);


发布者:admin,转转请注明出处:http://www.yc00.com/web/1713132509a2189306.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信