skyilyskyily.blog.chinaunix.net
skyily
全部博文(144)
2010年(16)
2009年(128)
Zane_Yu
tasteswe
zwrvvv
xiao888l
zimuqing
leilelei
Phyllis6
jonathan
denghai1
wbdwbd04
itTangze
lifj1234
18141908
AAABug
分类: C/C++
2009-04-20 14:36:32
代码是mousePressEvent事件的获得void ChessBoard::mousePressEvent(QMouseEvent *event){ int tmp_x = 0; int tmp_y = 0; tmp_x = event->x(); tmp_y = event->y(); if((tmp_x > point_x && tmp_x < point_x + 8*line) && (tmp_y > point_y && tmp_y < point_y + 8*line)) { if(mutex == 0) { if(chess[(tmp_x-point_x)/line][(tmp_y-point_y)/line] == 0) { arithmetic( (tmp_x-point_x)/line, (tmp_y-point_y)/line, 1); if(signal == 1) { chess[(tmp_x-point_x)/line][(tmp_y-point_y)/line] = 1; mutex = 1; emit(turn_red()); signal = 0; } } else mutex = 0; } else { if(chess[(tmp_x-point_x)/line][(tmp_y-point_y)/line] == 0) { arithmetic( (tmp_x-point_x)/line, (tmp_y-point_y)/line, 2); if(signal == 1) { chess[(tmp_x-point_x)/line][(tmp_y-point_y)/line] = 2; mutex = 0; emit(turn_blue()); signal = 0; } } else mutex = 1; } update(); } else { ; } if(total_num != 64) { get_chess_num(); }}
附件为:源码,不过不是人机对战,人机对战的我已经实现,不过算法过于简单,(我设计的电脑太笨了,不敢拿出来献丑),顾想求一算法,希望大家帮忙,谢过。 文件: bwchess.tar.gz 大小: 54KB 下载: 下载
上一篇: 有点惭愧
下一篇:GNU linux qt4下动画的简单控制
登录 注册