Prototype of a Flash game like Poux – Part 3

November 28th update: Finished project released

3rd update of the prototype. Remember to read part 1 and 2

It’s beginning to become something like a complete one-day game… let me introduce what I did.

First, I added cute graphics… on zeus box you will find some cute free icons with a completely free license, no matter what are you doing with such icons. I downloaded a Christmas pack so now the game looks like a Christmas game. I called the game “Christmas Couples”.

Then I added a score system, a time bar, some animations when you click on the icons, increasing difficulty, an highscore system, a game over status and a green “X2″ bonus bar acting like a 2X bonus if you remove an icon touching the bar.

Obviously, just in a few rows.

About the highscores, I used an ArmorBot account. Installing it is very easy and you can change almost everything in the highscore page. You can even add your own ad.

The page I made sucks a bit but it’s still under development… or maybe not… give it a look. At the moment you can only submit scores under the “triqui” name… but I am going to add a text field in the final version.

Anyway, let’s see the actionscript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// high scores
import ab3.rankz.*;
function __rankz_send__(par1, par2, par3, par4) { /* can't show you the content or you may cheat hiscores */ }
// declaration of the array that will contain the game
field = Array();
// number of icons actually removed
removed = 0;
// your score
score = 0;
// number of frames to pass before inserting a new row
interval = 250;
// position of the horizontal x2 multiplier
x2_horiz_pos = 0;
// multiplier bonus
mult = 1;
// is a game over?
game_over = 0;
// turns passed. A turn = a new row to insert
turns = 0;
// 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;
	}
}
// blue background
_root.attachMovie("bg", "bg", _root.getNextHighestDepth());
// x2 bonus
_root.attachMovie("x2_horiz", "x2_horiz", _root.getNextHighestDepth(), {_x:10});
// icons container
_root.createEmptyMovieClip("things", _root.getNextHighestDepth());
// time bar
_root.createEmptyMovieClip("bar", _root.getNextHighestDepth());
// score
_root.attachMovie("score", "score_obj", _root.getNextHighestDepth(), {_x:350, _y:20});
// 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 = things.attachMovie("tile", "tile_"+tiles_placed, tiles_placed, {_x:10+32*x, _y:300});
		num = Math.floor(Math.random()*6)+1;
		tile.gotoAndStop(num);
		field[x][0] = tiles_placed;
	}
}
// function to be executed at every frame
_root.onEnterFrame = function() {
	if (!game_over) {
		interval--;
		if (interval == 0) {
			turns++;
			// increasing difficulty
			interval = 250-turns;
			place_line();
			// moving x2 bonus bar
			x2_horiz_pos = Math.floor(Math.random()*10);
			x2_horiz._y = 300-x2_horiz_pos*32;
		}
		// showing time bar
		bar.clear();
		bar.lineStyle(6, 0xfff153);
		bar.moveTo(10, 350);
		bar.lineTo(328, 350);
		bar.lineStyle(4, 0xea8400);
		bar.moveTo(10, 350);
		bar.lineTo(10+318*interval/(250-turns), 350);
	}
};
// 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];
				things["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"
				// update: now IT IS game over
				things._alpha = 50;
				_root.attachMovie("ohno", "ohno", _root.getNextHighestDepth(), {_x:100, _y:95});
				game_over = 1;
				// Here I removed some lines to send high scores
			}
		}
	}
}
// when the player clicks...
onMouseDown = function () {
	if (!game_over) {
		// obtain tile clicked according to mouse position
		x_tile_clicked = Math.floor((_root._xmouse-10)/32);
		y_tile_clicked = -Math.floor((_root._ymouse-300)/32);
		if ((x_tile_clicked>=0) and (x_tile_clicked<=9) and (y_tile_clicked>=0) and (y_tile_clicked<=9)) {
			if (field[x_tile_clicked][y_tile_clicked] != 0) {
				remove_tiles(x_tile_clicked, y_tile_clicked, 1);
				update_field();
				// calculating score
				for (i=1; i<=removed; i++) {
					score += (i*mult);
				}
				score_obj.score.text = "Score: "+score;
				removed = 0;
				mult = 1;
			}
		}
	}
};
// removing tiles of the same color of the one clicked
function remove_tiles(tx, ty, clicked) {
	// checking tile color according to its current frame
	tile_type = things["tile_"+field[tx][ty]]._currentframe;
	// check if the tile to remove is the one you clicked. In this case, wait to have at least two tiles to remove
	if (!clicked) {
		// icon animation
		things["tile_"+field[tx][ty]].onEnterFrame = function() {
			this._y++;
			this._alpha--;
			if (this._alpha == 0) {
				this.removeMovieClip();
			}
		};
		field[tx][ty] = 0;
		removed++;
		if (ty == x2_horiz_pos) {
			// bonus
			mult = 2;
		}
	}
	if ((field[tx+1][ty] != 0) and (things["tile_"+field[tx+1][ty]]._currentframe == tile_type)) {
		remove_tiles(tx+1, ty);
	}
	if ((field[tx-1][ty] != 0) and (things["tile_"+field[tx-1][ty]]._currentframe == tile_type)) {
		remove_tiles(tx-1, ty);
	}
	if ((field[tx][ty+1] != 0) and (things["tile_"+field[tx][ty+1]]._currentframe == tile_type)) {
		remove_tiles(tx, ty+1);
	}
	if ((field[tx][ty-1] != 0) and (things["tile_"+field[tx][ty-1]]._currentframe == tile_type)) {
		remove_tiles(tx, ty-1);
	}
}
// update the field, making tiles fall if bottom tiles disappear
function update_field() {
	for (i=0; i<10; i++) {
		for (j=1; j<10; j++) {
			if ((field[i][j] != 0) and (field[i][j-1] == 0)) {
				falling = j-1;
				while ((field[i][falling] == 0) and (falling>=0)) {
					field[i][falling] = field[i][falling+1];
					things["tile_"+field[i][falling+1]]._y += 32;
					field[i][falling+1] = 0;
					falling--;
				}
			}
		}
	}
}

and this is the game

At the moment, if you die you have to reload the page. That’s life… play and don’t forget to look at the highscores to see if your score was awesome or you’re just a rookie….

Read the post about the finished project!!

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 19 comments

  1. Prototype of a Flash game like Poux - Part 2 : Emanuele Feronato - italian geek and PROgrammer

    on November 22, 2007 at 1:56 am

    [...] 22nd update: part 3 [...]

  2. Prototype of a Flash game like Poux : Emanuele Feronato - italian geek and PROgrammer

    on November 22, 2007 at 1:56 am

    [...] 17th update: part 2 released November 22nd update: part 3 released Ok, I know, you are asking for full tutorials and not prototypes, but you have to know [...]

  3. Hawdon

    on November 22, 2007 at 4:22 am

    lol im the 10th on the score board xD
    Nice tut!
    Vey good!
    Thx :D
    even Tho right now im working on a line rider

  4. shiv1411

    on November 22, 2007 at 9:03 am

    cooooooooool

  5. Frederik J

    on November 22, 2007 at 4:04 pm

    Good job emanuele. And nice theme! ;)
    Of course it could be better. But anyway, you’re teaching us in a great way :D

  6. Ed

    on November 22, 2007 at 6:35 pm

    Did you just make it you couldn’t reset because you couldn’t be bothered to make a reset button and get rid of all the complicated annoying variables and duplicated MCs? :P

    Nice tut, and I came 37th (though make it we can submit our scores) :)

  7. David

    on November 22, 2007 at 6:52 pm

    brilliant

    Emanuele, can you help me by having a tutorial on how to create a handbrake motion for a car?

  8. CGR

    on November 22, 2007 at 7:07 pm

    I got 10219 points, cool passtime.

  9. Tony

    on November 22, 2007 at 7:24 pm

    I miss some sounds or music. Good tut
    I can’t wait for the next platform tutorial!

    I was 3rd with 545.

  10. Tony

    on November 22, 2007 at 7:28 pm

    681! Now I’m second

    Watch out, CGR!

  11. ijjid

    on November 22, 2007 at 8:15 pm

    your tutorial is impressive for someone beginner like me!you rock!

    do you have tutorials on creating multiplayer flash games?i mean just the basic things to know and how to do it as what you did on you game tutorial(step by step)…it was really a great lecture for a beginner like me..i think i could create my own game out of it.thx!

  12. ijjid

    on November 22, 2007 at 8:19 pm

    by-the-way, im talking about the one you post in here: http://www.gotoandplay.it/_articles/2007/02/game_tutorial_part3.php

  13. shiv1411

    on November 24, 2007 at 1:33 pm

    hi emnauele,

    whats up?

    I was creating this game with multiple levels and when I published it, I saw one great bug. A player can simply roam through my levels just by right-clicking and then clicking play, he automatically advances to the next frame, or next level.

    Please tell me how can I solve this problem.

  14. Ed

    on November 24, 2007 at 1:40 pm

    shiv, have a look at this tutorial:

    http://www.newgrounds.com/portal/view/201218

    Take a look at the customizable right click menu.

  15. CGR

    on November 24, 2007 at 9:12 pm

    Ur almost there tony ^^

  16. Eblup

    on November 25, 2007 at 7:51 am

    hey can you plz make a AI tutoreal for a platform game? like you run around,attack, and other enemyes attack.

    if you can make code this complicated then cant you make AI enemys thet you can fight.
    oh and look at dead frontire!

  17. shiv1411

    on November 27, 2007 at 8:58 am

    thanks Ed,
    now I can give a good reply to those cheaters!

  18. dan

    on November 28, 2007 at 5:30 am

    hey
    could you post the source file here? i tried to code this but the background, scoreboard and multiplier bar dont show up.

    thanks

  19. Robert

    on May 2, 2011 at 4:03 pm

    hey..im messing with again..i made a game from it..and it did ok…trying to get back into actionscript..so dicided to mess with somethign i understood well once….got a question though…..how would i go about making the block progress to the next slide within itself….like i have an immage that i use..but when it begins to fade (this._alpha–) how would i make it go to the next slide in that blocks timeline….please and thank you