From 4dece19fcb1b37f593d4f4242fc2ec44445d790e Mon Sep 17 00:00:00 2001 From: "3190104610@zju.edu.cn" <3190104610@zju.edu.cn> Date: Mon, 18 Oct 2021 23:01:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=81=94=E6=9C=BA?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E9=94=99=E8=AF=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=BB=91=E7=99=BD=E6=96=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/APP_Gobang/APP_Gobang.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/User/APP_Gobang/APP_Gobang.c b/User/APP_Gobang/APP_Gobang.c index f8c4a05..9b6b00c 100644 --- a/User/APP_Gobang/APP_Gobang.c +++ b/User/APP_Gobang/APP_Gobang.c @@ -34,6 +34,9 @@ #define CHESS_RADIUS 5 +#define CONNETING_STATUS 0 +#define BATTLING_STATUS 1 + #define NONE_MSG 0 #define REQUEST_MSG 'R' #define AGREE_MSG 'A' @@ -63,6 +66,9 @@ int chess_kind = BLACK_CHESS; //我方执子类型 int my_turn = BLACK_TURN; +//当前所处状态 +int status = CONNETING_STATUS; + //联机消息 uint8_t connetion_msg = NONE_MSG; @@ -103,9 +109,10 @@ void APP_Gobang_Launcher(void) APP_Gobang_DispGobang(); if (APP_Gobang_Connect() == 0) return; + status = BATTLING_STATUS; HC12_BindReceiveHandle(NULL); - KEY_ClearKey(); HC12_ClearReceive; + KEY_ClearKey(); while (1) { @@ -149,6 +156,8 @@ void APP_Gobang_Init(void) cursor_x = cursor_y = 7; turn = BLACK_TURN; chess_kind = BLACK_CHESS; + status = CONNETING_STATUS; + connetion_msg = NONE_MSG; x_start = (LCD_WIDTH - LCD_HEIGHT) / 2 + interval / 2; x_end = x_start + (WIDTH - 1) * interval; @@ -162,10 +171,11 @@ void APP_Gobang_Init(void) void APP_Gobang_DispGobang(void) { GE_Draw_ClrAll(MAP_COLOR); - APP_Gobang_DispText(); APP_Gobang_DispMap(); APP_Gobang_DispChess(); APP_Gobang_DispCursor(); + if (status == BATTLING_STATUS) + APP_Gobang_DispText(); GE_Draw_Disp(); } @@ -581,14 +591,14 @@ void APP_Gobang_ConnectRevHandler(uint8_t byte) if (is_receiving == TRUE) { - if(byte==REQUEST_MSG||byte==AGREE_MSG||byte==REFUSE_MSG) + if (byte == REQUEST_MSG || byte == AGREE_MSG || byte == REFUSE_MSG) { connetion_msg = byte; is_receiving = FALSE; } - else if(byte=='0'||byte=='1') + else if (byte == BLACK_TURN || byte == WHITE_TURN) { - my_turn=byte-'0'; + my_turn = byte; is_receiving = FALSE; } }