Chess platform Production tutorial of bucket landlord selection algorithm

Source: Internet
Author: User

The first: In the queue of the card only you are selected, will respond to their own visible area, and the previous card in the lower part of the visible area.

This is the simplest, when you are selected, first change the normal visible area and then + Select the visible area.

When selected we change the y-coordinate of the card: the y-coordinate of the card = the y-coordinate of the card-checkhigh (the upward height after selection)

And then substituting the following

Normalrect.setrect (The x-coordinate of the card, the y-coordinate of the card, the x-coordinate of the card +cardwidth, the y-coordinate of the card +cardhigh);//This is the normal visible area after the change.

The following is a specific 4-point coordinate calculation (the algorithm is for reference only!) more chess platform making www.yasewl.com)

X-coordinate of the x1= card-cardspacing (spacing between cards)

The y-coordinate of the y1= card

X-coordinate of x2= card +cardwidth

Y2=y1+checkhigh (up to height after selection)

Visible area after selection: Topordown.setrect (X1,y1,x2,y2);


Then change the visible area of the lower part of the previous card.

X-coordinate of x1= card + cardspacing (spacing between cards)

Y-coordinate +checkhigh-checkhigh of the y1= card (up height after selection)

X-coordinate of x2= card + cardspacing (spacing between cards)

Y-coordinate +checkhigh of y2= card;

Topordown.setrect (X1,Y1,X2,Y2);

The normal visible area of the previous card does not change.


The second type: in the card's queue will affect the other cards visible area

This can be discussed in two different situations.

1 front three cards have been selected (the visible area of the front hand will be affected after selection)

When there are selected cards in the previous 3 cards, their visible areas will be affected and the normal visible areas will not be affected. and the visible area of the impact is just X2 changed, the visible area of influence we can use a formula to represent

X2= (Checkcardindex (Index of the selected card)-Forntcardindex (index of the previous selected card)-1) *cardspacing (spacing between cards).


2 after 3 cards have been selected (will affect the visible area of their own)

When we select the card, there are three cards to be selected. We first use the first: in the card queue only the method that you have been selected to calculate the normal visible area and visible area. And after the selection is affected by only X2, we also use a formula to express.

X2= (Backcardindex (Index of the selected card)-(Checkcardindex (index of selected cards))-1) *cardspacing (spacing between cards).

This way, when we select a card, we need to change the visible area as well as the visible area of the previous 3 selected cards.


In this way, when you click on the card, according to the mouse coordinates, to determine which card in the queue of the visible area of the collision, and then determine the index of the card to change the visible area of the corresponding card to achieve the selection of the operation of the card

Chess platform Production Tutorial bucket landlord selection algorithm

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.