|
|
|
@ -327,7 +327,7 @@ def drawButton22(screen):
|
|
|
|
|
screen.blit(button_fail.image, button_fail.rect)
|
|
|
|
|
button_restart = Button(pg.transform.scale(pg.image.load("Image/restart.bmp"),(100,50)),(100,0))
|
|
|
|
|
screen.blit(button_restart.image, button_restart.rect)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -449,7 +449,15 @@ def main(mode):
|
|
|
|
|
clock.tick(60)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawButton22(screen)
|
|
|
|
|
#drawButton22(screen)
|
|
|
|
|
button_stop = Button(pg.transform.scale(pg.image.load("Image/叫停.bmp"), (100, 50)), (400, 0))
|
|
|
|
|
screen.blit(button_stop.image, button_stop.rect)
|
|
|
|
|
button_quit = Button(pg.transform.scale(pg.image.load("Image/退出.bmp"), (100, 50)), (300, 0))
|
|
|
|
|
screen.blit(button_quit.image, button_quit.rect)
|
|
|
|
|
button_fail = Button(pg.transform.scale(pg.image.load("Image/认输.bmp"), (100, 50)), (500, 0))
|
|
|
|
|
screen.blit(button_fail.image, button_fail.rect)
|
|
|
|
|
button_restart = Button(pg.transform.scale(pg.image.load("Image/restart.bmp"), (100, 50)), (100, 0))
|
|
|
|
|
screen.blit(button_restart.image, button_restart.rect)
|
|
|
|
|
while running:
|
|
|
|
|
#! 特别注意:红方是0,蓝方是1
|
|
|
|
|
#print('current moving color: ',game_state.color())
|
|
|
|
@ -524,7 +532,64 @@ def main(mode):
|
|
|
|
|
sys.exit()
|
|
|
|
|
elif e.type == pg.MOUSEBUTTONDOWN:
|
|
|
|
|
#鼠标点击事件:用于选择棋子,移动棋子
|
|
|
|
|
if game_over and other_joined:
|
|
|
|
|
if e.button == 1:
|
|
|
|
|
if button_quit.rect.collidepoint(e.pos):
|
|
|
|
|
quitJson = {
|
|
|
|
|
"type": 2,
|
|
|
|
|
"msg": {
|
|
|
|
|
"request": "quit",
|
|
|
|
|
"game_id": game_id,
|
|
|
|
|
"side": MySide
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.send(json.dumps(quitJson).encode('utf-8'))
|
|
|
|
|
pg.quit()
|
|
|
|
|
sys.exit()
|
|
|
|
|
if not game_over and not other_stage and other_joined:
|
|
|
|
|
if e.button == 1:
|
|
|
|
|
if button_quit.rect.collidepoint(e.pos):
|
|
|
|
|
quitJson = {
|
|
|
|
|
"type": 2,
|
|
|
|
|
"msg": {
|
|
|
|
|
"request": "quit",
|
|
|
|
|
"game_id": game_id,
|
|
|
|
|
"side": MySide
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.send(json.dumps(quitJson).encode('utf-8'))
|
|
|
|
|
pg.quit()
|
|
|
|
|
sys.exit()
|
|
|
|
|
if button_stop.rect.collidepoint(e.pos):
|
|
|
|
|
winJson = {
|
|
|
|
|
'type': 2,
|
|
|
|
|
'msg': {
|
|
|
|
|
'request': 'stop',
|
|
|
|
|
'game_id': game_id,
|
|
|
|
|
'side': MySide
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.send(json.dumps(winJson).encode("utf-8"))
|
|
|
|
|
if button_fail.rect.collidepoint(e.pos):
|
|
|
|
|
quitJson = {
|
|
|
|
|
"type": 2,
|
|
|
|
|
"msg": {
|
|
|
|
|
"request": "quit",
|
|
|
|
|
"game_id": game_id,
|
|
|
|
|
"side": MySide
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.send(json.dumps(quitJson).encode('utf-8'))
|
|
|
|
|
if button_restart.rect.collidepoint(e.pos):
|
|
|
|
|
reportJson = {
|
|
|
|
|
"type": 2,
|
|
|
|
|
"msg": {
|
|
|
|
|
"request": "report",
|
|
|
|
|
"game_id": game_id,
|
|
|
|
|
"side": MySide
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
client.send(json.dumps(reportJson).encode('utf-8'))
|
|
|
|
|
mouse_loc = pg.mouse.get_pos()
|
|
|
|
|
row = int((mouse_loc[1] - bias_top) / SIZE)
|
|
|
|
|
col = int((mouse_loc[0] - bias_left) / SIZE) #* get position of mouse click
|
|
|
|
|