\*******'w'加速,'s'减速,'a','d'转向************\
#include <bios.h>
#include <math.h>
#include <graphics.h>
#include <stdio.h>
#include <time.h>
#include <dos.h>
#define PI 3.14159265
#define r 15
#define c(c) setfillstyle(1,c)
main()
{int x=320,y=240,x0=320,y0=240;float v=0,t=0,a=0;
char k='0';
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc2\\bgi");
setcolor(15);
setwritemode(XOR_PUT);
while(k!='q')
{while(bioskey(1)==0)
{printf("t=%f,v=%f,a=%f(%d,%d)\r",t,v,a,x,y);
if(x<=0||x>=639)a=PI-a;if(y<=0||y>=479)a=-a;
x=v*cos(a)*t+x;y=v*sin(a)*t+y;
line(x0,y0,x,y);
circle(x,y,5);
delay(5000);
circle(x,y,5);
x0=x;y0=y;
t+=0.01;
}
k=bioskey(0);
switch(k)
{case 'a': a-=0.1;break;
case 'd': a+=0.1;break;
case 's': v-=0.1;break;
case 'w': v+=0.1;break;
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |