C语言贪吃蛇游戏的设计与实现(国外英文资料)
C语言贪吃蛇游戏的设计与实现(国外英文资料)
It's a rule of thumb, and my game is no exception. In addition to the end of the game screen, I also set up a game screen, "finish". With the above divided, I divided the whole process into (13+2) modules (actually function) 2.2.3 program structure (Liu Chengtu) figure 2.1 flow chart according to the need to deal with the task requirements, planning input data and output results, determine the data structure of the data is stored. In C language, the data structure is concentrated in the data type, so in the C language programming, we should plan the variables, array, pointer, and their types in the program as a whole. This is important, and if you choose inappropriate variables or arrays during this period, it will be very difficult to modify them in the future. Now analyze the elements of the snake game, and then come up with their corresponding description in the program: Snake: Basic Description: length, color, position. The corresponding data and data types: length - although you can use the coordinates, but in this case, the computation will be great, so the conversion into larger units - the number of nodes, each section describes the fixed length integer coordinates; color; integer; position --X, Y coordinates. Added Description: the direction of snake movements, snake life. Corresponding data and data types: these descriptions are for the input part of the program's key and are linked to the end of the game. There are only four directions: up and down. You can set the corresponding four integer numbers: 3, 4, 2, 1. There are only two instances of life: death or birth, corresponding to 0 or 1. Food: Basic Description: color, position. The corresponding data and data types are no longer discussed because the colors are fixed. Location - X and Y coordinates. An added Description: the existence of food. The corresponding data and data types are set up to avoid repeated food, which is related to the function that draws the food. Only two v