#include<math.h>
#include<mem.h>
#include<dos.h>
#include<stdlib.h>
#define p_num 2000
struct _Particle
{
float vx,vy,ax,ay,x,y;
unsigned char c;
};
void SetColor(int c,int r,int g,int b)
{
outportb(0x3c6,255);
outportb(0x3c8,c);
outportb(0x3c9,r>>2);
outportb(0x3c9,g>>2);
outportb(0x3c9,b>>2);
}
char far *GetBuffer(long x,long y)
{
return (char far *)(0xa0000000L+x+y*320);
}
void blur()
{
unsigned char far *p, far *q;
for(p=GetBuffer(1,1),q=GetBuffer(318,198);p<q;p++) *p=*(p-1)+*(p+1)+*(p-320)+*(p+320)>>2;
}
void main()
{
struct _Particle pg[p_num];
float fcos,fsin,t=0.01,angle=0.0;
float RGB[256][3];
int i;
int dx,dy;
memset(pg,0,p_num*sizeof(struct _Particle));
for(i=0;i<p_num;i++)
{
pg[i].x=160;
pg[i].y=100;
pg[i].c=255;
pg[i].ax=rand()%10191/1000.0-5;
pg[i].ay=rand()%8191/1000.0-4;
}
for(i=0;i<256;i++) RGB[i][0]=sqrt(i)/16.0;
for(i=0;i<256;i++) RGB[i][1]=pow(i,0.7)/48.5;
for(i=0;i<256;i++) RGB[i][2]=(i*i)/65536.0;
_AX=0x13;
asm int 0x10;
for(i=0;i<256;i++) SetColor(i,RGB[i][0]*256,RGB[i][1]*256,RGB[i][2]*256);
while(inportb(0x60)!=1)
{
fcos=cos(angle);
fsin=sin(angle);
for(i=0;i<p_num;i++)
{
pg[i].vx+=pg[i].ax*t;
pg[i].vy+=pg[i].ay*t;
pg[i].x+=pg[i].vx*t;
pg[i].y+=pg[i].vy*t;
dx=(pg[i].x-160)*fcos-(100-pg[i].y)*fsin+160;
dy=(pg[i].x-160)*fsin+(100-pg[i].y)*fcos+100;
if(dx>0&&dx<319&&dy>0&&dy<199) *GetBuffer(dx,dy)=pg[i].c;
if(dx<0||dx>=320) pg[i].vx=-pg[i].vx;
if(dy<0||dy>=200) pg[i].vy=-pg[i].vy;
}
blur();
angle+=0.01;
}
_AX=0x03;
asm int 0x10;
}
for tC + dos
----------------解决方案--------------------------------------------------------
...又是老K怎么搞的?迷糊..哈哈..这么好
拿它去和我们老师炫耀下~!
----------------解决方案--------------------------------------------------------
我编译时这个不行啊!asm int 0x10;
----------------解决方案--------------------------------------------------------
for tC + dos
楼上的...
----------------解决方案--------------------------------------------------------
能不能说一下这个程序是干什么用的,怎么运行?
各位版主能不能介绍几本C程序设计进阶的书籍啊
[此贴子已经被作者于2006-4-9 16:53:28编辑过]
----------------解决方案--------------------------------------------------------
??
----------------解决方案--------------------------------------------------------
先看看
----------------解决方案--------------------------------------------------------
明显...我用不起.... for tc dos...
----------------解决方案--------------------------------------------------------
我用了,看起太漂亮了!!1
----------------解决方案--------------------------------------------------------
强,但这不是纯C,有许多汇编
----------------解决方案--------------------------------------------------------