Android game development-my little game 2-video connection Game 3-video connection algorithm 1

Source: Internet
Author: User

There are three main cases for determining whether a connection can be made through review.

1. There is no inflection point during the connection, which is further divided into horizontal and vertical

2. There is an inflection point during connection.

3. There are two inflection points during the connection, which is also the most difficult part of the game.

First, let's see if there is no inflection point.

// Determine the public Boolean ishorizontal () in the horizontal direction {// used to record the large number, the small number int bignumx = 0; int smallnumx = 0; // first determine the level line if (lastclick [1] = curclick [1]) {If (lastclick [0]> curclick [0]) {bignumx = lastclick [0]; smallnumx = curclick [0];} else if (lastclick [0] <curclick [0]) {bignumx = curclick [0]; smallnumx = lastclick [0];} // If (smallnumx + 1 = bignumx) {return true ;} else // not adjacent {for (INT I = smallnumx + 1; I <= bignumx; I ++) {If (pieces [I] [lastclick [1] = 1) // if there is a square block between the two sides, return false; else return true ;}} return false ;} // determine public Boolean isvertical () {int bignumy = 0; int smallnumy = 0; If (lastclick [1]> curclick [1]) in the vertical direction {bignumy = lastclick [1]; smallnumy = curclick [1];} else if (lastclick [1] <curclick [1]) {bignumy = curclick [1]; smallnumy = lastclick [1];} // If (smallnumy + 1 = bignumy) {return true;} else {for (INT I = smallnumy + 1; I <bignumy; I ++) {If (pieces [lastclick [0] [I] = 1) // if there is a square block between the two sides, return false; else return true;} return false ;}

Related Article

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.