This is the “micro channel small game development actual combat” series of the eighth, this series we will start from 0, make a 1010 game.

If you don’t have any experience in game development, you can read my “Anyone Can Make Games” series, which will guide you hand in hand to make your first wechat game.

The small game development tool used in the tutorial is wechat official small game production tool: wechat small game production tool

In “1010” the player constantly drags the graphics below into the grid, and when a row or column is filled, elimination scores are scored. In this video we’re going to learn how to do elimination.

After the shape is placed on the grid, the grid data is traversed and checked. If the elimination condition (1 for each row or column of data) is met, the squares of the current row or column are removed.

Add a new block material to the project and rename it “Grid Data Management”. We’ll put all the logic related to grid data on this one. It doesn’t show up in the game, it just checks and processes grid data for us in the background. I’ll do it in blue to distinguish it from other objects.

Create two global lists: Global-Matching row and Global-Matching Column. Record all the row and column numbers that meet the conditions.

Create two new notifications. The grid Data Validation notification tells us when to validate data. The “Remove matching square” notification tells us when to go for elimination.

Next, look at the logic in “Grid Data Validation.”

Just seems pretty long, but the logic is not complicated, first check line by line in the grid data, records meet the conditions of line, and then one by one check, record meet the conditions listed, check and traversal of grid data we deal with data (using the form) in the second quarter is detailed in the said before, if forget, can go to review them.

Let’s move on to elimination.

The logic is simple: if there is currently a matching row or column, all fill squares are notified and eliminated.

Finally, take a look at the logic for filling the square.

The logic in the previous section was to create the fill square by placing it at the corresponding position in the grid and setting the data for the corresponding position in the grid to “1”.

In the next part, when receiving the notification of “Remove matching square”, determine whether your row number and column number are in “global-matching row” or “global-matching column”, if so, delete yourself and reset the grid data of the corresponding position to “0”.

When should data in the grid be checked and erased? When we place the graphics on the grid, of course. Select “container-1” and add a notification block at the end of the shape.

As shown, once the shape is placed on the grid, a notification is sent telling Grid Data Management that it is ready to start checking and eliminating the data.

Preview it and see what the elimination looks like.

Eliminate a row.

Eliminate two columns.

To sum up:

In this section, we learned how to eliminate squares in the grid, again checking the grid data to see if rows and columns meet the elimination criteria, and then deleting the fill squares by using notification.

Practice:

Did you drag and fill all your other shapes? If so, then implement the elimination of other shapes.


If you are interested in game development and want to know more original content and tutorials related to game development, please follow my official account: Little Ant Game Development.

If you think the article is good, please click a “like” to give me some motivation, thanks ~