<commit_before>---
title:  "Match 3 game Part 2 - Obstacles and bombs"
date:   2017-07-01 10:00:00 +0200
tags: Match3
---
New elements have been added to the game: bomb pieces and indestructible obstacle tiles.
<!--more-->

While the column slide effect was already included in the previous version it would only work during piece removal and refilled pieces simply popped out of nowhere. This was quite easy to fix: the **CreatePiece()** method now has a vertical offset and a movement time parameter. If the offset is bigger than 0, the pieces are instantiated above the board and "fall into place" with the given speed. Notice that **CreateRandomPiece()** has been rewritten into the more generic **CreatePiece()** method so it is now possible to create a certain kind of gamepiece.

Another new feature is the introduction of obstacle tiles. The player cannot interact with these and they block gamepieces. They can be used to create a more interesting level shape. The **Tile** class got a brand new **TileType** enum which currently contains Basic and Obstacle. Gamepiece fill and column slide now only work if the tile is not an obstacle. **Board** also got an array containing **PresetTile** structures so it is much easier to set up a starting board state from the editor.

![Obstacle tiles]({{site.url}}/assets/images/obstacle-tiles.PNG){: .align-center}
*Obstacle tiles*
{: .text-center}

The biggest addition since the last version is the inclusion of bombs. I considered different approaches and finally decided to implement bombs as separate GameObjects attached to gamepieces. They have their own sprite renderers and **Bomb** scripts. This script doesn't contain much: the type of the bomb, an **Init()** method and some code to automatically replace the bomb sprite if the bombtype is altered in the editor. The sprites are only simple markers which appear on a layer above the gamepieces. This way I can see immediately that the gamepiece has a certain kind of attached bomb.

[Copy code snippet](#link){: .btn}  

{% highlight c# %}
<commit_msg>Extension fix<commit_after>---
title:  "Match 3 game Part 2 - Obstacles and bombs"
date:   2017-07-01 10:00:00 +0200
tags: Match3
---
New elements have been added to the game: bomb pieces and indestructible obstacle tiles.
<!--more-->

While the column slide effect was already included in the previous version it would only work during piece removal and refilled pieces simply popped out of nowhere. This was quite easy to fix: the **CreatePiece()** method now has a vertical offset and a movement time parameter. If the offset is bigger than 0, the pieces are instantiated above the board and "fall into place" with the given speed. Notice that **CreateRandomPiece()** has been rewritten into the more generic **CreatePiece()** method so it is now possible to create a certain kind of gamepiece.

Another new feature is the introduction of obstacle tiles. The player cannot interact with these and they block gamepieces. They can be used to create a more interesting level shape. The **Tile** class got a brand new **TileType** enum which currently contains Basic and Obstacle. Gamepiece fill and column slide now only work if the tile is not an obstacle. **Board** also got an array containing **PresetTile** structures so it is much easier to set up a starting board state from the editor.

![Obstacle tiles]({{site.url}}/assets/images/obstacle-tiles.png){: .align-center}
*Obstacle tiles*
{: .text-center}

The biggest addition since the last version is the inclusion of bombs. I considered different approaches and finally decided to implement bombs as separate GameObjects attached to gamepieces. They have their own sprite renderers and **Bomb** scripts. This script doesn't contain much: the type of the bomb, an **Init()** method and some code to automatically replace the bomb sprite if the bombtype is altered in the editor. The sprites are only simple markers which appear on a layer above the gamepieces. This way I can see immediately that the gamepiece has a certain kind of attached bomb.

[Copy code snippet](#link){: .btn}  

{% highlight c# %}

{'fraction_non_alphanumeric': 0.06637596899224807, 'fraction_numerical': 0.01065891472868217, 'mean_word_length': 4.53485254691689, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6188373', 'n_tokens_mistral': 1053, 'n_tokens_neox': 984, 'n_words': 633}