The greedy snake game written in C #, simple

Source: Internet
Author: User
Tags visual studio
These days playing mobile phone greedy snake play into the fan, want to write a play on the computer, also as a programming practice.

Greedy Snake game demand:
1. Play: Similar to Nokia mobile phone on the greedy snake, but with the keyboard key or mouse to control the movement of snakes.
2. Appearance: In order to reduce the difficulty, just write a rectangle on a form to show the location of the greedy snake movement, the greedy snake is like the kind of Nokia mobile phone, with a few squares composed on the line.
3. Eat beans: Snake every eat a bean, the length of the snake to increase one, score plus 5 points. (like a snake without beans)
4. Death: The death of a snake when it collides with a wall or its own body.

Running environments and programming languages
As a result of this time learning C #, the natural idea is to use the C # language to write this little game. After we complete this demo, we'll use Java to implement it.

Programming bad; Visual Studio. NET 2003 Chinese version
Operating system: Windows 2000 or above.

Use object-oriented usage to abstract some of the following classes:
A floor class that represents the place where snakes move.
Snake class, indicating snakes
Block class, which represents the blocks that make up a snake, where we think the snake object is made up of a piece of block object.
Bean class, which means beans,
There are detailed comments in the source program.

Next Update features:
1. Add the scoring function. The snake eats a single bean and scores one.
2. Snake speed increases with score.
3. Add keyboard control function, use arrow keys to control the direction of snake movement


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.