MouseHit

这个函数用于检测当前是否有鼠标消息。

bool MouseHit();

 

参数

返回值

如果存在鼠标消息,返回 true;否则返回 false。

示例

void Show_Extend() { //cleardevice(); Date_IMAGE_Init(); Play = { 400,350,169,52, BLACK,"简单模式" }; Introduce = { 400, 404, 169, 52, BLACK, "困难模式" }; Upgrade_of_Combat = { 400, 456, 169, 52,BLACK, "炼狱模式" }; while(1) { // 贴图 & 绘制按键 DrawAlpha_Transparent(&img_tmp_Extend, 0, 0, &img_Extend); DrawAlpha_Transparent(&img_tmp_Extend, Play.x, Play.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, Introduce.x, Introduce.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, Upgrade_of_Combat.x, Upgrade_of_Combat.y, &img_Extend_Button); DrawAlpha_Transparent(&img_tmp_Extend, 100, 0, &Plane_Game); putimage(0, 0, &img_tmp_Extend); DrawImage_BUTTON(&Play); DrawImage_BUTTON(&Upgrade_of_Combat); DrawImage_BUTTON(&Introduce); FlushBatchDraw(); // 按键判断 if (MouseHit()) { MOUSEMSG msg = GetMouseMsg(); if (Switch_Buton(&Play, msg.x, msg.y)) Play.color = RGB(234, 54, 128); else Play.color = BLACK; if (Switch_Buton(&Upgrade_of_Combat, msg.x, msg.y)) Upgrade_of_Combat.color = RGB(234, 54, 128); else Upgrade_of_Combat.color = BLACK; if (Switch_Buton(&Introduce, msg.x, msg.y)) Introduce.color = RGB(234, 54, 128); else Introduce.color = BLACK; switch (msg.uMsg) { case WM_LBUTTONDOWN: if (Switch_Buton(&Play, msg.x, msg.y)) // 简单模式 { enemya_num = 12; v_enemyb = 3; v_enemyc = 5; BOSS_Damage = 5; BOSS_num = 12; goto next; } if (Switch_Buton(&Upgrade_of_Combat, msg.x, msg.y)) // 困难模式 { enemya_num = 15; v_enemyb = 6; v_enemyc = 8; BOSS_Damage = 8; BOSS_num = 15; goto next; } if (Switch_Buton(&Introduce, msg.x, msg.y)) // 炼狱模式 { enemya_num = 20; v_enemyb = 9; v_enemyc = 10; BOSS_Damage = 15; BOSS_num = 20; goto next; } } } } next: Init_Button(); f[0] = 0; cleardevice(); }请为上述程序画出流程图
05-24
解释一下这段代码int main() { int i = 0; //表示接受鼠标点击次根据奇偶判断棋子颜色 int qicolor = 0; int x = 0, y = 0; //x,y为游戏坐标 initgraph(640, 500); loop1: int flag = 0; //标记那种颜色该走了 MOUSEMSG m; init(); setfillstyle(BS_SOLID); setfillcolor(BLUE); bar(520, 0, 640, 500); setbkmode(TRANSPARENT); setcolor(RED); settextstyle(20, 0, _T("宋体")); outtextxy(530, 250, _T("请红方落子")); while (1) { if (MouseHit()) { m = GetMouseMsg(); if (m.uMsg == WM_LBUTTONDOWN) { x = (m.x - 35) / 30; //列坐标 y = (m.y - 35) / 30; //行坐标 if ((x >= 0 && x < 15) && (y >= 0 && y < 15) && map[y][x] == 0) if (flag == 0) { flag = 1; qicolor = RED; draw(y, x, qicolor); map[y][x] = qicolor; if (judge(y, x, qicolor)) { HWND hwnd = GetHWnd(); if (MessageBox(hwnd, _T("红方胜利 \n重来一局吗?"), _T("询问"), MB_YESNO | MB_ICONQUESTION) == IDYES) goto loop1; else break; } setfillstyle(BS_SOLID); setfillcolor(RED); bar(520, 0, 640, 500); setcolor(BLUE); settextstyle(20, 0, _T("宋体")); outtextxy(530, 250, _T("请蓝方落子")); } else { flag = 0; qicolor = BLUE; draw(y, x, qicolor); map[y][x] = qicolor; if (judge(y, x, qicolor)) { HWND hwnd = GetHWnd(); if (MessageBox(hwnd, _T("蓝方胜利 \n重来一局吗?"), _T("询问"), MB_YESNO | MB_ICONQUESTION) == IDYES) goto loop1; else break; } setfillstyle(BS_SOLID); setfillcolor(BLUE); bar(520, 0, 640, 500); setcolor(RED); settextstyle(20, 0, _T("宋体")); outtextxy(530, 250, _T("请红方落子")); } } } } gameover(); _getch(); closegraph(); return 0; }
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值