Rexrainbow Board series tutorial #4 Click remove, and make it a game

2

Index

Attached Files

The following files have been attached to this tutorial:

.capx
.png

Stats

6,773 visits, 12,859 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 3 Mar, 2016. Last updated 19 Feb, 2019

Chapter 1. Click Remove

~~~~~~~~~~~~~~~~~~~~

Finally we are coming to the final part of this series! To assembly everything and make it a Poptile game, we still need a critical function: click remove. This function is the most difficult one through out whole the game (so I put it in the last tutorial). Traditionally to perform a click remove in match-3 game, you'll need to implement flood fill algorithm which will let you feel dizzy and fall to asleep quickly. But thanks for Rexrainbow's <Board> series plugins again, we can do this more intuitivly and easily by <SLG Movement> plugin.

<SLG Movement> plugin is design for SLG games. The greatest part is that you can use it to detect moveable area and implement path finding function for your SLG games. So you may think: "Why are we going to use it here for click remove function? We are not making a SLG!". OK, let's take a look at below picture:

On the left-side we have a 7x7 match-3 game. And on the right-side we have a analogy SLG terrian map. I just transfer green chess to grass, yellow chess to dessert, blue chess to sea, and red chess to wall. Now if player click one of the green chess and we have to find connected green chess to remove (marded in dashline), it will be similar to put a SLG character on corresponding tile and find its moveable area (marked in dash line). So we turned this click remove problem to be a moveable area problem, and <SLG Movement> plugin is the perfect solution for this case. Now let's start to edit our C2 project.

Change to <Layout 1> and add <SLG Movement> and <Touch> plugin.

Chage to <Event sheet 1> and add the following codes:

Firstly, we add a new global text variable symbol_to_remove. This varaible to buffer the symbol name of clicked chess to assist <SLG Movement>'s operation.

Next, Event26 triggers "touch_remove" function and jump to Event22. You can see that we send the UID of clicked chess to function, and pick the chess back when entering the function. This guarentee all the actions in this function applies to only the touched chess. The most important action in Event#22 is <SLG>-><Get moveable area>. Once you can understand this aciton, you'll be level-up in C2 coding. Now we introduce each of the parameters in this action:

Chess parameter assigns the character object to move. Moving points represent for the mobility of the character. It could be set to any non-zero points in our case. Moving cost is a function which defines the mobility cost of each terrian, and Filter is a function which defined the operations to take when <SLG Movement> find one moveable tile. We will add these two function in Event#23 & 25. Group is a specified group name of <InstGroup> to store the chess which are filtered out by Filter function.

While the action is over, all the chess on moveable tiles will be stored in "touch_remove" group in <InstGroup>. But it doesn't contains the the original clicked chess. So we add the original chess and pick all chess out, then flash them and destroy.

Event#23 defines the cost fuction and we name it "cost_func". This function will be called iteratively by <SLG Movement> plugin. When it is called, we pick the chess above current tile. If this chess has the same symbol to our target symbol, then we set its moving cost to 0 point. Otherwise the cost will be infinity and make this tile a immovable blocker.

Event#25 defines the fillter function and we name it "filter_func". This function will be called everytime <SLG Movement> finds a moveable tile. When this happens we pick the chess above current tile, and store the chess to "touch_remove" group.

OK, now disable Event#3 temporarily and push <F4> to run layout. Now we have click remove function in our game.

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • This needs a million C3 Plugins just to open it.

    Think you can list all the plugins needed for use with C3?

    It's kind of useless unless you provide all the plugins for the current version of Construct.

    Error:

    The project you are opening uses the following addons that are not installed. Try installing these missing plugins, behaviors and effects and then re-open the project.

    Plugin Matcher (Rex_Matcher) by Rex.Rainbow

    Plugin Board (Rex_SLGBoard) by Rex.Rainbow

    Plugin SLG movement (Rex_SLGMovement) by Rex.Rainbow

    Plugin Square Tx (Rex_SLGSquareTx) by Rex.Rainbow

    Plugin Wait Event (Rex_WaitEvent) by Rex.Rainbow

    Plugin Inst Group (Rex_gInstGroup) by Rex.Rainbow

    Behavior Grid Move (Rex_GridMove) by Rex.Rainbow

    Behavior Chess (Rex_chess) by Rex.Rainbow