Skip to content

Chinese_chess_game#67

Open
zyb-0609 wants to merge 1 commit intoopen-vela:devfrom
zyb-0609:chinese-chess
Open

Chinese_chess_game#67
zyb-0609 wants to merge 1 commit intoopen-vela:devfrom
zyb-0609:chinese-chess

Conversation

@zyb-0609
Copy link

This is a Chinese Chess (Xiangqi) game example built with LVGL, demonstrating piece selection, movement, and win/loss detection.

Features:

Piece selection and movement: Tap a piece to select it, then tap a target position on the board to move it.

Capture rules: Opponent pieces can be captured, including the General; capturing the opponent’s General ends the game.

Intuitive interaction: Simple touch-based controls suitable for embedded device demonstrations.

Demo GIF:
chinese_chess_game

showcasing the complete flow of piece selection, movement, and game-ending conditions.

@zyb-0609 zyb-0609 changed the title chinese_chess_game Chinese_chess_game Jan 29, 2026
{black_che_1,black_ma_1,black_xiang_1,black_shi_1,black_jiang,black_shi_2,black_xiang_2,black_ma_2,black_che_2}
};

const lv_style_prop_t transition_props[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like not to be used. better to remove it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like not to be used. better to remove it.

Hello, thank you for your suggestion. I have removed the unused variables in the revised program. Could you please take a look and let me know if there are any remaining issues or suggestions for improvement?

@zyb-0609 zyb-0609 force-pushed the chinese-chess branch 5 times, most recently from f1830ae to 1eb718c Compare February 2, 2026 15:50
@zyb-0609 zyb-0609 closed this Feb 2, 2026
@zyb-0609 zyb-0609 reopened this Feb 2, 2026
@zyb-0609 zyb-0609 force-pushed the chinese-chess branch 3 times, most recently from 4bfbe19 to b696468 Compare February 2, 2026 16:28
@@ -0,0 +1,29 @@
#
# Copyright (C) 2022 Xiaomi Corporation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add CMakeLists.txt as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMakeLists.txt

Thank you for your suggestion. I have now added the CMakeLists.txt file.

lv_obj_set_pos(Black_bing_5,Board_Xvalue[piece[black_bing_5].Xvalue]-35,Board_Yvalue[piece[black_bing_5].Yvalue]-35);
}

static void app_create_main_page(void)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app_create_main_page and position_init functions have highly repetitive code—shall we merge them into one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app_create_main_page and position_init functions have highly repetitive code—shall we merge them into one?

Thank you for your suggestion. In the newly submitted code, I have merged them together.

lv_obj_set_pos(Black_bing_2,Board_Xvalue[piece[black_bing_2].Xvalue]-35,Board_Yvalue[piece[black_bing_2].Yvalue]-35);
lv_obj_set_pos(Black_bing_3,Board_Xvalue[piece[black_bing_3].Xvalue]-35,Board_Yvalue[piece[black_bing_3].Yvalue]-35);
lv_obj_set_pos(Black_bing_4,Board_Xvalue[piece[black_bing_4].Xvalue]-35,Board_Yvalue[piece[black_bing_4].Yvalue]-35);
lv_obj_set_pos(Black_bing_5,Board_Xvalue[piece[black_bing_5].Xvalue]-35,Board_Yvalue[piece[black_bing_5].Yvalue]-35);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format the code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format the code

Thank you for your suggestion. I have now adjusted the code accordingly. If there are any further issues, please let me know.

static void app_create_main_page(void)
{

position_init();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code format use webkit style

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg. clang-format-14 --style=WebKit -i Chinese_Chess/Chinese_chess.c

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg. clang-format-14 --style=WebKit -i Chinese_Chess/Chinese_chess.c

Thank you for your suggestion. I have already used this command to change the code style to WebKit style.

lv_obj_set_pos(Red_elephant_2,Board_Xvalue[piece[red_xiang_2].Xvalue]-35,Board_Yvalue[piece[red_xiang_2].Yvalue]-35);
//Add red shi
Red_shi_1 = lv_image_create(root);
lv_image_set_src(Red_shi_1,images.redshi);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Hello, I have now also modified the code style for this part. Please let me know if there are any other issues.

Chinese_chess_game

Chinese_chess_game
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants