match-3-game-source-code
Nov 28

What is Match 3 Game Source Code?

By: Anna Louise

Match 3 games source code are some of popular games in market. From Bejeweled to Candy crush fames are fully enjoyed and used by many users and are components of classic age old generic of matching games. Now goal is simple- swap pieces around till there is three or more in row. If a match-2 is made, these tiles are also eliminated and empty space is properly filled. It allows player rack-up potential combos and many points.

In this tutorial you will learn a lot-

  • You need to create a board filled with tiles of games
  • Select & Deselect tiles by mouse click
  • Mention adjacent tiles with ‘raycast’ and swap tiles
  • Fill empty tiles after matching, keep score and count it

Match 3 game Source Code

public static BoardManager instance;     // 1

public List<Sprite> characters = new List<Sprite>();     // 2

public GameObject tile;      // 3

public int xSize, ySize;     // 4

private GameObject[,] tiles;      // 5

public bool IsShifting { get; set; }     // 6

void Start () {

instance = GetComponent<BoardManager>();     // 7

Vector2 offset = tile.GetComponent<SpriteRenderer>().bounds.size;

CreateBoard(offset.x, offset.y);     // 8}

private void CreateBoard (float xOffset, float yOffset) {

tiles = new GameObject[xSize, ySize];     // 9

float startX = transform.position.x;     // 10

float startY = transform.position.y;

for (int x = 0; x < xSize; x++) {      // 11

for (int y = 0; y < ySize; y++) {

GameObject newTile = Instantiate(tile, new Vector3(startX + (xOffset * x), startY +             (yOffset * y), 0), tile.transform.rotation);

tiles[x, y] = newTile;

}        }    }

It is also important for us to get success with this game. You should analyze components of Match 3 Game. Each component is assigned a score from 0-3.

0 : Not present.

1 : Present, but not significant.

2 : Present, but used occasionally.

3 : Present and significant.

 

Responses