跪求用VC++编写的简单点的小游戏程序源代码,谢谢

 我来答
百度网友d4931ea
2011-12-18 · TA获得超过547个赞
知道小有建树答主
回答量:166
采纳率:0%
帮助的人:142万
展开全部
#include<graphics.h>
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#define PI 3.1415926
#define x0 320
#define y0 240

DrawClock(int x,int y,int color)
{
int r=150;
setcolor(color);
circle(x,y,r);
circle(x,y,2);
}

DrawHand(int x,int y,float th,int l,int color)
{
int x1,y1;
x1=x+l*sin(th);
y1=y-l*cos(th);
setcolor(color); setlinestyle(0,0,3);
line(x,y,x1,y1);
}

main()
{
int gdriver=DETECT;int gmode;
int size; void *buf; int *s[]={"3 hours","2 hours","1 hour","12 hours","11 hours","10 hours","9 hours","8 hours","7 hours","6 hours","5 hours","4 hours"};int i,j,color;
int *p[]={"15 minsec","10 minsec","5 minsec","60 minsec","55 minsec","50 minsec","45 minsec","40 minsec","35 minsec","30 minsec","25 minsec","20 minsec"};
struct time curtime;
float th_hour,th_min,th_sec;

initgraph(&gdriver,&gmode,"");
setbkcolor(0);

while(! kbhit())
{
setbkcolor(13); cleardevice();
srand(1);
DrawClock(x0,y0,1);
setlinestyle(0,0,3);
setcolor(1);circle(320,240,170);

gettime(&curtime);
gotoxy(35,20);

if((float)curtime.ti_hour<=12)
{printf("AM");
if((float)curtime.ti_hour<10)printf("0");
printf("%.0f:",(float)curtime.ti_hour);
}
else
{printf("PM");
if((float)curtime.ti_hour-12<10)printf("0");
printf("%.0f:",(float)curtime.ti_hour-12);
}

if((float)curtime.ti_min<10)printf("0");
printf("%.0f:",(float)curtime.ti_min);

if((float)curtime.ti_sec<10)printf("0");
printf("%.0f:",(float)curtime.ti_sec);

th_sec=(float)curtime.ti_sec*0.1047197551;
th_min=(float)curtime.ti_min*0.1047197551+th_sec/60.0;
th_hour=(float)curtime.ti_hour*0.523598775+th_min/12.0;
for(i=0;i<12;i++)
{
setcolor(15);settextstyle(0,0,1);
outtextxy(320+150*cos(i*30*PI/180),240-150*sin(i*30*PI/180),s[i]);
setcolor(14);settextstyle(0,0,1);
outtextxy(320+190*cos(i*30*PI/180),240-190*sin(i*30*PI/180),p[i]);
}

DrawHand(x0,y0,th_hour,70,2);
DrawHand(x0,y0,th_min,110,3);
DrawHand(x0,y0,th_sec,140,12);

for(i=1;i<12;i++)
for(j=1;j<12;j+=2)
{
color=rand()%14+1;
putpixel(i,j,color);
}

size=imagesize(0,0,12,12);
buf=(void*)malloc(size);
if(!buf)return -1;
getimage(0,0,12,12,buf);
for(i=0;i<130;i+=3)
{
putimage(1+i,1+i,buf,COPY_PUT); putimage(1+i,1+i,buf,OXR_PUT);
putimage(640-i,1+i,buf,COPY_PUT);putimage(640-i,1+i,buf,OXR_PUT);
putimage(1+i,480-i,buf,COPY_PUT);putimage(1+i,480-i,buf,OXR_PUT);
putimage(640-i,480-i,buf,COPY_PUT); putimage(640-i,480-i,buf,OXR_PUT);

}

sleep(1);
cleardevice();
}
closegraph();
}


推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式