模拟小球弹跳~C实现
网上的大部分小球弹跳都是用TC实现的,需要用到graphics.h ~今天兔兔分享一个小球弹跳的实现DEV C++通过喔~
太麻烦了 不截图了 可以直接编译运行
#include <iostream>
#include <conio.h>
#include <time.h>
#include <windows.h>
void dump(int x, int y)
{
COORD c;
c.X = x;
c.Y = y;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
int main()
{
int x=15,y=4,depth=20,times=20,m=1,i,j;
for (;depth!=0;)
{
m=-m;
if(m==1)
depth–;
for (i=1;i<=depth;i++)
{
dump(x,y);
printf(“O”);
for (j=1;j<=times;j++)
Sleep(5);
system(“cls”);
if(m==-1)
{
y++;
times–;
}
else
{
y–;
times++;
}
}
}
getch();
return 0;
}
抢沙发,顺便YM兔兔
有没有demo看看的
迅速撤下俊文的链接,原博客已转让
仰慕兔兔。这个不错啊;用“O”来做小球;
我复制代码到dev-c++里面、引号竟然变成全角了;
还有那自减操作少了一个“-”;
大D来催更!