Do you like my tutorials?

Then consider supporting me on Ko-fi

Talking about Poux game, Flash and Game development.

November 17th update: part 2 released
November 22nd update: part 3 released
November 28th update: Finished project released

Ok, I know, you are asking for full tutorials and not prototypes, but you have to know that a prototype is the first step to a tutorial and some of you realized nice games starting from prototypes or “incomplete” tutorials.

Anyway, I promise I’ll continue all “open” tutorials.

Today I am introducing you the prototype of a Flash game like Poux

Poux

Poux is a fast and challenging board game you have to click on contiguous same colored tiles to remove them.

Time is running fast and adds a new line of tiles at the bottom. Bombs can eliminate a whole line of tiles. Use them wisely.

You can play a nice version of Poux at LightForce.

In this prototype I have only an object linked as “tile” that contains all tiles, one per frame.

In the first and only frame of the main stage, the code is:

// declaration of the array that will contain the game
field = Array();
// number of frames to pass before inserting a new row
interval = 50;
// tiles placed so far
tiles_placed = 0;
// loop that initializes the field
for (x=0; x<10; x++) {
	field[x] = Array();
	for (y=0; y<10; y++) {
		field[x][y] = 0;
	}
}
// function that places a line of tiles in the bottom of the field
function place_line() {
	for (x=0; x<10; x++) {
		tiles_placed++;
		// if the spot is not empty, must shift the colum
		if (field[x][0] != 0) {
			push_blocks(x);
		}
		tile = attachMovie("tile", "tile_"+tiles_placed, tiles_placed, {_x:10+32*x, _y:300});
		num = Math.floor(Math.random()*8)+1;
		tile.gotoAndStop(num);
		field[x][0] = tiles_placed;
	}
}
// function to be executed at every frame
_root.onEnterFrame = function() {
	interval--;
	if (interval == 0) {
		interval = 50;
		place_line();
	}
};
// function that shifts the column of blocks
function push_blocks(col_number) {
	for (i=9; i>=0; i--) {
		if (field[col_number][i] != 0) {
			if (i != 9) {
				field[col_number][i+1] = field[col_number][i];
				_root["tile_"+field[col_number][i]]._y -= 32;
			} else {
				// if I have more than 10 blocks in a column, remove the 10th block
				// In a normal game, it would be "game over"
				_root["tile_"+field[col_number][i]].removeMovieClip();
			}
		}
	}
}

… and in only 50 lines (comments and brackets included) we have the field populating with a new row of tiles every 50 frames.

I will complete the game very soon. Or maybe one of you will have a clue and complete the game for me. I will be happy to host his tutorial.

This is the source code… then move to part 2.

Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.