[As feature code tutorial 13] Greedy snake

Source: Internet
Author: User

Ideas:

1. First specify the Movement area width (stagew) and height of the snake (Stageh)

2. Increase the keyboard to listen, get the keying code, if the key and the previous key is reversed will not change

3. In the initialization, please note: The size of the snake head, snake body, food is 7 pixels

4. Each moving step (move) is 8 pixels in order to achieve the body of a lattice of the effect

5. After eating food, the length of the snake body is increased by 5 units, copying 5 bodies

6. Crawler forward: Starting from the tail, the last one to follow the position of the previous one, the first following the snake head

Icon:

1. The whole idea

2. Snake head, snake body, food size are 7 pixels, step 8 pixels

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.