void draw(float stateTime) { image(myroad,0+right,115); image(sce,0+rights,0); image(car,carx,70); //image(wheel,200+30,40+51); //image(wheel,200+167,40+51); imagerotated(wheel,carx+30,70+51,angel); imagerotated(wheel,carx+167,70+51,angel); // //carx=carx+200; if(stop==TRUE) { //停止 right=right-0; rights=rights-0; angel=(angel+0)%360; } else { if(carx>=200) { if(rights<=-640) rights=0; if(right<=-640) right=0; else { if(fast==TRUE) { right=right-10; rights=rights-8; angel=(angel+50)%360; } /*else { right=right-5; rights=rights-3; angel=(angel+5)%360; }*/ else if(low==TRUE)//减慢 { right=right-2; rights=rights-1; angel=(angel+1)%360; } else { right=right-5; rights=rights-3; angel=(angel+5)%360;//正常轮子的速度 } } } else { carx=carx+2; angel=(angel+5)%360; } } color(248,246,188); fillcircle(100,60,45); int i; for(i=1;i<=12;i++) { color(0,0,0); cx=100+35*sin(30*i*3.14/180); cy=60-35*cos(30*i*3.14/180); if(i%3==0) circle(cx,cy,5); else circle(cx,cy,2); } time_t now; struct tm *tm_now; int hour,minute,sed; float hx,hy,mx,my,sx,sy; time(&now); tm_now=localtime(&now); hour=tm_now->tm_hour; minute=tm_now->tm_min; sed=tm_now->tm_sec; hx=100+20*sin((hour%12+minute*1.0/60)*30*3.14/180);//时针终点坐标 hy=60-20*cos((hour%12+minute*1.0/60)*30*3.14/180); line(100,60,hx,hy); mx=100+25*sin(minute*6*3.14/180); my=60-25*cos(minute*6*3.14/180); line(100,60,mx,my); sx=100+33*sin(sed*6*3.14/180); sy=60-33*cos(sed*6*3.14/180); line(100,60,sx,sy); }的参数和返回值和功能
时间: 2024-03-08 09:44:58 浏览: 27
该函数的参数为浮点数 stateTime,表示当前的时间状态。函数的功能是在屏幕上绘制一个小车、时钟和道路等图形。其中,myroad、sce、car、wheel 是图像对象,分别表示道路、背景、小车和轮子的图像。right、rights、carx、angel 是整型变量,分别表示道路和背景的偏移量、小车的横坐标、轮子的旋转角度。stop、fast、low 是布尔型变量,表示小车的运动状态。该函数没有返回值。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)