3. Detailed explanation of the maze (mini games)
I took some time this morning to summarize the problem of the Maze last night. If you are interested, please take a look.
This overall approach is similar to the course design we used last semester. The same C language and modular design only have some handle knowledge.
A: The header file should be understandable;
B: Required modular functions:
In terms of the interface (void facemap (), void win (), void start (), three
One (void gotoxy (int x, int y) and one
Void facemove, 1
Void facemove (color setting function), 1,
Main function (main), 1.
C: Main Function
When setting a flag variable as a condition, it is also feasible to use 1 directly in terms of memory saving.
Welcome Page → go to the maze map → start walking
D: color setting function
Handle variable (hconsole), handle is equivalent to a data type;
The standard output handle getstdhandle (std_output_handle) is to change the corresponding color in the output window;
Bool setconsoletextattribute (handle hconsoleoutput, word wattributes); this is the prototype of the color setting function. It has two parameters: the first is the console handle variable, and the second is the color control parameter, the details are as follows:
E: Maze Map
The so-called maze map is to set a two-dimensional array and output it, it is very easy to understand. Sleep (100) is a latency of 100 milliseconds. the header file is # include <windows. h>
F: move the cursor
Printf ("% C", 2) will output a smiling face;
Swith () is based on your input (front and back), to determine whether the corresponding position is a space, if it is a space to prove that this road is accessible, the cursor points to the smiling face, with a space to cover the smiling face, the cursor points to the feasible position and outputs a new smiling face at that position, thus achieving the moving of the smiling face visually. In fact, a new smiling face is generated at the next position, and the previous smiling face has been covered by spaces. When it reaches the leftmost, It is the exit and the exit is completed.
G: Exit Interface
This module is easy to understand and I will not talk about it much.
H: Welcome Page
Similar.
This is all the content of this maze. I personally think the difficulty lies in the understanding of the combination of the cursor and smiling face, and the judgment of the wall, which is a little hard to understand, however, I changed the student's method and used spaces to indicate that it is feasible. This seems quite understandable. If the wall is used as a condition, a black square is two bytes. The P [m] [N] you use to determine can only represent one byte, and you need to solve this conflict. Solution: Split the double-byte Chinese characters to-88 on the left and 126 on the right. Then you can use them as conditions to determine. In fact, I am not doing well in the beautification of the maze. I have some ideas to add them, but I am not doing well in the beautification, such as the harmony of colors, so that it is not good.
By Zhang Hui
October 24, 2014
3. Detailed explanation of the maze (mini games)