Here we are with the 3rd step of the tutorial. Today we will let the player collect items if he selects at least three of them with the same color.
The changes to be made to the script are very simple. First we need another property in tileObject object called val, an integer which will range from 1 to 6.
This will allow us to create six different kind of tiles, which must be represented by as may frames in Tile symbol. I used six different colors.
Then, a valid move is defined as a move which groups at least three tiles oft he same color, so if the player performs a valid move, selected tiles are removed from the stage and new ones appear, this way:
Tiles do not fall down like in the original game, but you should be able to do it since it’s the same concept used during the making of Bejeweled.
Here is the source code:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
public class Main extends Sprite {
private var fieldWidth:int=8;// field width, in tiles
private var fieldHeight:int=6;// field height, in tiles
private var tileSize:int=80;// tile size, in pixels
private var tileVector:Vector.
Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.