圣手书生,恭祝大家,春节快乐
代码并不复杂,这里分别讲解一下。
粒子系统的设计:
struct Cell{
int x, y, tx, ty, len;
int s, e;
int color;
void show(int t){
if (t>=s and t<=e){
int x1= x+ (tx-x)*(t-s)/(e-s);
int y1= y+ (ty-y)*(t-s)/(e-s);
if (x1>=0 && y1>0 && y1<MAXY){
setColor(color);
gotoxy(x1,y1);
cout << "*";
}
}
if (t>=s+len and t<=t+len){
int tt= t-len;
int x1= x+ (tx-x)*(tt-s)/(e-s);
int y1= y+ (ty-y)*(tt-s)/(e-s);
if (x1>=0 && y1>0 && y1<MAXY){
gotoxy(x1,y1);
cout << " ";
}
}
}
} cells[2000];
粒子的信息基本参数:起点x,y,终点x,y,有效长度,可见时间,消失时间,颜色。</