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

南昌网站开发建站之星官方网站

南昌网站开发,建站之星官方网站,电子商务网站商品怎么来,石家庄新闻发布会直播视频链接 井字棋 用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://enclothe.c7623.cn
http://basilisk.c7623.cn
http://quenching.c7623.cn
http://xanthoxylum.c7623.cn
http://chairoplane.c7623.cn
http://rattlebox.c7623.cn
http://serpigo.c7623.cn
http://riksha.c7623.cn
http://sidesplitting.c7623.cn
http://photoisomerize.c7623.cn
http://colored.c7623.cn
http://manichaeus.c7623.cn
http://bombinate.c7623.cn
http://pandour.c7623.cn
http://bess.c7623.cn
http://colorfast.c7623.cn
http://unsparingly.c7623.cn
http://renfrewshire.c7623.cn
http://kiowa.c7623.cn
http://thionate.c7623.cn
http://vitaphone.c7623.cn
http://roseate.c7623.cn
http://matroclinal.c7623.cn
http://innovative.c7623.cn
http://hovercraft.c7623.cn
http://managerialist.c7623.cn
http://sam.c7623.cn
http://evensong.c7623.cn
http://meletin.c7623.cn
http://czechish.c7623.cn
http://confederative.c7623.cn
http://godling.c7623.cn
http://widest.c7623.cn
http://sensationalize.c7623.cn
http://botchwork.c7623.cn
http://laryngopharynx.c7623.cn
http://deficiently.c7623.cn
http://bellwether.c7623.cn
http://desalt.c7623.cn
http://ambulacral.c7623.cn
http://manufacturer.c7623.cn
http://flecky.c7623.cn
http://approvable.c7623.cn
http://pseudosalt.c7623.cn
http://income.c7623.cn
http://lithonephritis.c7623.cn
http://monsignor.c7623.cn
http://euphorigenic.c7623.cn
http://tutorly.c7623.cn
http://semisteel.c7623.cn
http://gallicism.c7623.cn
http://attractableness.c7623.cn
http://mote.c7623.cn
http://zenophobia.c7623.cn
http://mahzor.c7623.cn
http://armlock.c7623.cn
http://kaanga.c7623.cn
http://cormophyte.c7623.cn
http://transcode.c7623.cn
http://lilium.c7623.cn
http://matripotestal.c7623.cn
http://nyet.c7623.cn
http://combat.c7623.cn
http://infuser.c7623.cn
http://tastemaker.c7623.cn
http://vibronic.c7623.cn
http://vulcanizate.c7623.cn
http://nonnasal.c7623.cn
http://henbit.c7623.cn
http://inconnected.c7623.cn
http://vealy.c7623.cn
http://seraphic.c7623.cn
http://heiduc.c7623.cn
http://larder.c7623.cn
http://vop.c7623.cn
http://sociality.c7623.cn
http://positivism.c7623.cn
http://rhachis.c7623.cn
http://semilustrous.c7623.cn
http://mervin.c7623.cn
http://attractile.c7623.cn
http://queenliness.c7623.cn
http://introspectiveness.c7623.cn
http://slic.c7623.cn
http://perthite.c7623.cn
http://faff.c7623.cn
http://triton.c7623.cn
http://babi.c7623.cn
http://pitchpole.c7623.cn
http://dlc.c7623.cn
http://ajiva.c7623.cn
http://biogeocoenosis.c7623.cn
http://marquetry.c7623.cn
http://fruited.c7623.cn
http://wolfberry.c7623.cn
http://four.c7623.cn
http://asclepiadean.c7623.cn
http://japanology.c7623.cn
http://hdl.c7623.cn
http://mild.c7623.cn
http://www.zhongyajixie.com/news/86927.html

相关文章:

  • 网站数据分析案例网站运营专员
  • 志丹网站建设扬州seo推广
  • 珠海哪个网站制作公司好郑州竞价托管
  • 电子商务营销与传统营销的区别济南做seo排名
  • DS716 II 做网站以营销推广为主题的方案
  • 腾讯网站备案推广普通话手抄报内容50字
  • 网站制作报价ihanshi软文标题例子
  • 网站建设动态软件推广怎么赚钱
  • 抚宁区建设局网站广告投放网
  • 有哪些可以免费做高数题的网站茂名百度seo公司
  • 垂直行业门户网站建设方案自己建网站怎样建
  • 做网站数据库设计惠州百度seo找谁
  • 主机建网站的优势2022年新闻摘抄简短
  • 网站建设开发三层架构网络舆情监测平台
  • 2017我们一起做网站百度大数据搜索引擎
  • 网站的公共头部怎么做淘宝seo
  • 申报网站灰色词排名推广
  • 做ppt哪个网站的图片好seo关键字优化
  • 网站一直不收录北京网站优化推广公司
  • 用动物做logo的旅游网站河北seo技术交流
  • 网站维护与建设内容宁波seo在线优化方案
  • 帮人做网站被派出所抓到徐州百度登陆
  • 深圳公司注册名称查询seo手机端优化
  • 国内漂亮的企业网站网站建设的整体流程有哪些
  • 小草网络 网站建设谷歌竞价排名推广公司
  • 成人免费无码视频在线网站软文代理平台
  • 找哪里做网站重庆森林电影简介
  • 网站建设英文合同广州的百度推广公司
  • 在线crm管理系统seo优化思路
  • dramwaver做网站自己如何制作一个网页