c ++ Snake

Display: clear screen print double-digit group, namely an array of game maps, including walls, snakes and food.

Snake's body is connected with the structure:

struct snake{
    int x;
    int y;
    struct snake *next;
}head,body1,body2,tail;

The initial length of the snake 4, head represents a head, and its next point to NULL; tail represents tail, tail added after eating before the body was added.

 

Complete code: https://github.com/shuiguai/games/blob/master/snake.cpp

Environment: win64, VS2010

Guess you like

Origin www.cnblogs.com/DarkMario/p/11012663.html