After this course design, I found some general ideas for the design of small games. Here, we will discuss some of our questions, such as DoS games, such as mine clearance, push box, maze, and push box, you can basically draw a game area as M * n, and map the area to an array of M * n. You can set 0 and 1 in the array to determine the game status and rules, determine whether the game wins or loses. Of course, different games can use different algorithms, but all game templates can be implemented using this idea.
In the case of mine clearance, because the ray in the program is divided into 64 areas, it can be treated as an array with 64 elements, each time you click through the mouse to obtain the current screen coordinates, return the position of the element through the xytono subroutine (0 ...... 63) when the left button is determined, obtain the corresponding elements of the array from the array storing thunder, and then determine whether the current element is thunder, if it is a ray, it is switched to the stop judgment and the SI (Entry parameter) is 0. If it is not a ray, the element is output (this element is the number of surrounding mines ), right-click the user status array and the corresponding element is 'x'. The output 'F' in the corresponding coordinate area of the screen indicates the flag number-1. If the flag number is zero, the SI value is set to 12, call Stop Judgment.
If Si is 12, the data at the record location is read from the user status array and compared with the corresponding location of the record storage array, if one-to-one matching is possible, the corresponding prompt is displayed for win. If Si is 0 or when the mine position is determined to be incorrect, the corresponding prompt is displayed for lose.
In another case, the box, obstacle, and wall can be regarded as elements in the array and then composed of multiple elements. When the element is 1, the road ahead is blocked, when the value is 0, the front width is determined, whether the streamer can enter, and so on until the box completely reaches several elements (exit), and the game ends.
Later, I played a bullet box game. After careful observation and research, I found that the game can also be implemented using a similar idea. The algorithm may be to calculate the incident angle and shooting angle when the ball (Bitmap) hits the wall, at the same time, determine the racket position. If the position element value is 1 (the same as the obstacle value of the Wall, square, and so on), it will pop up. If it is 0, it will be lost, and the ball will not fly out.
This is the basic idea I have summarized. I hope to help myself and my friends in the future programming life.