当前位置: 首页 > news >正文

南昌网站开发最新国际新闻50条简短

南昌网站开发,最新国际新闻50条简短,泰州网站建设公司,做投标网站条件视频链接 井字棋 用EasyX和C实现井字棋小游戏 源码及注释 #include<graphics.h>char board_data[3][3] {{-,-,-},{-,-,-},{-,-,-}, };char current_piece O;//检测指定棋子的玩家是否获胜 bool CheckWin(char c) {// 检查每一行for (int i 0; i < 3; i){if (bo…

视频链接

井字棋

用EasyX和C++实现井字棋小游戏

源码及注释

#include<graphics.h>char board_data[3][3] =
{{'-','-','-'},{'-','-','-'},{'-','-','-'},
};char current_piece = 'O';//检测指定棋子的玩家是否获胜
bool CheckWin(char c)
{// 检查每一行for (int i = 0; i < 3; i++){if (board_data[i][0] == c && board_data[i][1] == c && board_data[i][2] == c)return true;}// 检查每一列for (int j = 0; j < 3; j++){if (board_data[0][j] == c && board_data[1][j] == c && board_data[2][j] == c)return true;}// 检查对角线if (board_data[0][0] == c && board_data[1][1] == c && board_data[2][2] == c)return true;if (board_data[0][2] == c && board_data[1][1] == c && board_data[2][0] == c)return true;// 如果没有匹配,则返回 falsereturn false;
}//检测当前是否出现平局
bool CheckDraw()
{for (size_t i = 0; i < 3; i++) {for (size_t j = 0; j < 3; j++) {if (board_data[i][j] == '-')return false;}}return true;
}//棋盘
void DrawBoard()
{line(0, 200, 600, 200);line(0, 400, 600, 400);line(200, 0, 200, 600);line(400, 0, 400, 600);}//棋子
void DrawPiece()
{for (size_t i = 0; i < 3; i++) {for (size_t j = 0; j < 3; j++) {switch (board_data[i][j]){case 'O':circle(200 * j + 100, 200 * i + 100, 100);break;case 'X':line(200 * j, 200 * i, 200 * (j + 1), 200 * (i + 1));line(200 * (j+1), 200 * i, 200 * j , 200 * (i + 1));break;case '-':break;default:break;}}}
}//提示
void DrawTipText()
{static TCHAR str[64];_stprintf_s(str, _T("当前棋子类型: %c"), current_piece);settextcolor(RGB(225, 175, 45));outtextxy(0, 0, str);
}int main()
{initgraph(600, 600);bool running = true;ExMessage msg;BeginBatchDraw();while (running){DWORD start_time = GetTickCount();//自系统启动以来经历的毫秒数while (peekmessage(&msg)){//检查鼠标左键按下的信息if (msg.message == WM_LBUTTONDOWN){//计算点击位置int x = msg.x;int y = msg.y;int index_x = x / 200;int index_y = y / 200;//落子操作if (board_data[index_y][index_x] == '-') {board_data[index_y][index_x] = current_piece;//切换棋子类型if (current_piece == 'O') current_piece = 'X';else current_piece = 'O';}}}cleardevice();DrawBoard();DrawPiece();DrawTipText();FlushBatchDraw();if (CheckWin('X')){MessageBox(GetHWnd(), _T("X 玩家获胜"), _T("游戏结束"), MB_OK);running = false;}else if (CheckWin('O')){MessageBox(GetHWnd(), _T("Y 玩家获胜"), _T("游戏结束"), MB_OK);running = false;}else if (CheckDraw()){MessageBox(GetHWnd(), _T("平局!"), _T("游戏结束"), MB_OK);running = false;}DWORD end_time = GetTickCount();//自系统启动以来经历的毫秒数DWORD delta_time = end_time - start_time;//作差的到这次循环所消耗的时间if (delta_time < 1000 / 60) // 为了确保60hz刷新{Sleep(1000 / 60 - delta_time);//控制每次循环的时间消耗,而进行线程休眠}}EndBatchDraw();return 0;
}
http://www.zhongyajixie.com/news/13836.html

相关文章:

  • 知名做网站费用搜索引擎优化指的是什么
  • 济南网站设计价格百度游戏排行榜
  • 怎么开通自己的微信小程序标题优化怎样选关键词
  • 网站系统平台建设近期的新闻热点
  • framework7做网站零基础学seo要多久
  • sns社交网站 有哪些免费宣传平台
  • 做网站不难吧网络推广怎么收费
  • 服饰工厂网站建设百度搜索推广开户
  • 网站开发前端学习做神马seo快速排名软件
  • 电脑网页视频怎么下载广州seo优化排名公司
  • 织梦网站logo更改小说关键词生成器
  • 注册资本随便填了500万seo和sem推广
  • 中山建公司网站域名注册价格及续费
  • 重庆建设工程信息网官网安全监督信息seo深圳网络推广
  • 专门做汽车gps贷款网站全媒体广告代理
  • 那里可以免费建网站十大营销策略有哪些
  • wordpress音频播放搜索引擎优化包括
  • 廊坊建设质量监督局网站重庆关键词seo排名
  • 做搜狗pc网站软件seo机构
  • 关于加强网站建设与管理的通知网络推广策划方案怎么写
  • 济南怎样做网站推广seoer是什么意思
  • 建设银行网站邮箱磁力搜索引擎2023
  • 网站建设课程有哪些收获2021百度热搜年度榜
  • 南阳专业做网站公司品牌策划设计
  • 大方县住房城乡建设局网站谷歌优化推广
  • 淘宝天猫做网站咨询百度竞价渠道代理
  • 竞价网站制作网站seo设置是什么
  • 上虞做网站数据分析师培训
  • 烟台电商网站建设高端企业网站建设
  • 重庆建设委员会官方网站app推广拉新渠道