#include <stdio.h>
#include <windows.h>
struct dow
{
char nei[10][100];
char speed[10];
char colo[10];
};
struct dow DM={{"11111","22222","333333","44444","55555","66666","7777","88888","99999","1010101"},
{2,3,5,4,1,2,7,9,3,4},{2,3,5,4,1,2,7,9,3,4}};
/*移动光标位置*/
void gotoxy(int x, int y)
{
HANDLE hout;
COORD pos;
pos.X = x;
pos.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, pos);
}
/*隐藏光标*/
void show_cursor(int hide)
{
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hout;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hout, &cciCursor))
{
cciCursor.bVisible = hide;
SetConsoleCursorInfo(hout, &cciCursor);
}
}
/*设置颜色*/
void set_color(int color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
void col(int color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color);
}
int main()
{
int color = 1;
int x = 0, y = 0;
int t=1;
int a;
int aa[10],bb[10];
show_cursor(0);
for(a=0;a<10;a++)
{
bb[a]=aa[a]=120-strlen(DM.nei[a]);
}
while(1)
{
system("cls");
for(a=0;a<10;a++)
{
col(DM.colo[a] );
gotoxy(aa[a],a);
printf("%s", DM.nei[a]);
if(aa[a]>=0)
{
aa[a]=aa[a]-DM.speed [a];
}
else
{
aa[a]=bb[a];
}
}
Sleep(100);
}
}
C语言实现弹幕
最新推荐文章于 2024-10-22 20:46:20 发布