Implementation of chess games

Source: Internet
Author: User

Implementation of chess games

After a week of intermittent work, I finally completed a simple chess game, but now I can only entertain myself. Next I will study AI...

Talk about your basic ideas


1. There are two main types of Board and chess sub-classes APices. APices is an abstract class. Because different chess pieces have different action rules, they must be implemented in the derived class;
2. The basic lines are drawn using GDI. To facilitate the implementation of click events, both classes inherit the sub-Panel;
3. How To Move pawns:
First, define the intersection of the checker line as the usable point of the chess piece, and draw a rectangle centered on this point. When you click in this rectangle, determine whether the movement rules are met, determines whether to move the pawns to the corresponding coordinates;
4. How to eat pawns:
Determine whether the coordinates of the selected and currently clicked pawns comply with the moving rules. Here, the gun is special, because his moving rules are different from eating sub-rules and need to be handled separately; the system uses Visible to hide a piece that has not been actually released;
5. regret:
The stack is used to store records. If you move the records, the coordinates at the beginning and end are reversed. If you eat them, you need to display the hidden pawns;


If you are interested, you can download it and make progress together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.