该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
#include
#includevoid zhuye()
{
IMAGE back,button; loadimage(&back, L"picture\\背景.jpg",800,600);
loadimage(&button, L"picture\\开始.jpg",100,50);
putimage(0, 0, &back);
putimage(300, 520, &button); settextcolor(WHITE);
RECT x = { 0, 0, 639, 420 };
drawtext(_T("骰子游戏"), &x, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
RECT r = { 0, 0, 639, 479 };
drawtext(_T("用户与电脑轮流掷6次,每次掷的点数累加,"), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
RECT d = { 0, 0, 639, 550 };
drawtext(_T("用每次掷的点数累加,最终点数最大的胜出."), &d, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
RECT q = { 0, 0, 639, 600 };
drawtext(_T("请点击开始游戏来游玩游戏"), &q, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}int Menu()
{
zhuye();
int shu=0;
MOUSEMSG msg;
do {
msg = GetMouseMsg();
if (msg.uMsg=WM_LBUTTONDOWN)
{
if((msg.x>0 && msg.x<800) && (msg.y>0 && msg.y<500))
shu = 1;
}
}
while (shu == 0);
return shu;
}void yemian2()
{
IMAGE img;
loadimage(&img,L"picture\\photo.jpg");
putimage(0,0,&img);
}int shubiao()
{
zhuye();
int shu=0;
MOUSEMSG msg;
do {
msg = GetMouseMsg();
if (msg.uMsg=WM_LBUTTONDOWN) {
if((msg.x>0 && msg.x<800) && (msg.y>0 && msg.y<500))
shu = 1;
}
}
while (shu == 0);
return shu;
}
void tupian()
{
TCHAR DIANSHU[6];
yemian2();
IMAGE img[6];
int k;
k=rand()%6+1;
_stprintf(DIANSHU, _T("picture\\%d.jpg"), k);
loadimage(&img[k],DIANSHU, 112, 112);
putimage(300,300, &img[k]);
}
void shuchu()
{
switch(rand()%6+1 )
{
case '1':
tupian();
Sleep(1000);
break;
case '2':
tupian();
Sleep(1000);
break;
case '3':
tupian();
Sleep(1000);
break;
case '4':
tupian();
Sleep(1000);
case'5':
tupian();
Sleep(1000);
case'6':
tupian();
Sleep(1000);
}
}
void zhitouzi( )
{
int i,j,d1,d2;
srand((unsigned)time(NULL));
rand();
d1= d2= 0;
{
for(i=1; i<=6; i++)
j=rand()%6+1;
d1 = d1+j+1;
shuchu(); }
if(d1>d2)
printf("\nYou win.\n");
else
if (d1
printf("\nBOT win.\n");
else
printf("平局\n");
}
void game()
{
switch(shubiao())
case'1':
zhitouzi();}void main()
{
initgraph(800, 600);
switch(Menu())
{
case'1':
yemian2();
game();
break;
}
getch();
}