Winter vacation period, think of C language can develop a snake game should be a good thing! But the C language learning process has always been the character interface programming, how can have "graphical" effect? So the small part of the Niang,
Google and other web site search, found some useful Win32 API functions, so the small part of the heart suddenly excited up, with these API functions may be able to achieve yo! Let's go!
Before programming, the idea of small series is such that the snake games should be achieved by:
1. The snake should be able to move independently under conditions of no control.
2. The player can control the direction of the snake through WASD keys.
3. During operation, if the snake hits the wall or its own body, the game is over, giving a message.
4. When a food is eaten, the next food should appear immediately, in a random position.
The plan starts on January 20 and ends on January 22 for a total of three days. After the goal is set, the work begins formally!
The development process of the snake is gradual, the small part is first from the realization of the site, and then to the realization and movement of the body of the snake, and then the realization of food, and finally the player through the keyboard to control the direction of the snake. In fact, the mini-series began on January 20.
It didn't end until January 23, for a total of 4 days. Beyond the expected day. The main use of the development is a variety of WIN32 API functions, such as the original control of the cursor position, the player hit the keyboard listener, as well as the interface background color and so on. The tool used in small series is the Codeblocks integrated development environment, a very small IDE, in short, after 4 days of development, the final finished product and the expected target is basically the same. Here are the following:
C-language mini-game development of Snake