How to use a Flash game tutorial to make your own game

When I stated writing tutorials, I did not expect I would have to write a tutorial about… using a tutorial.

If you look at the most recent games published, you’ll find a lot of games are useless clones of some of my tutorials or some of Tony Pa‘s ones.

I said “useless” because a tutorial is not meant to be a complete game… so if you just add your name and the game name to a tutorial, be sure that it will be a game that sucks, no matter how good is the tutorial.

In order to use a tutorial to make your own game, you need to follow some rules.

Let’s see them

Because it would be too easy to use a tutorial of mine to create a game, I’ll use Tony Pa’s tile based tutorials.

The first one is “Creating Tiles” and that’s where I am going to start.

1) Resize the movie

The first thing you have to do is resizing the movie to your needs. Remember that tutorials are often embedded in blogs or websites, so their sizes depend on pages layout. Your game will be played on gaming portals that will display it on popups (like NG) or on liquid pages that will fit to your game.

In my case, I am converting Tony’s file into a 512×256 movie, so I had to add some tiles to the map

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
fscommand("allowscale", false);
fscommand("allowscale", false);
// our map is 2-dimensional array
myMap = new Array()
myMap[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
myMap[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
myMap[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
myMap[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
myMap[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
myMap[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
myMap[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
myMap[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
// declare game object that holds info
game = {tileW:32, tileH:32};
// walkable tile
game.Tile0 = function() {
};
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
// wall tile
game.Tile1 = function() {
};
game.Tile1.prototype.walkable = false;
game.Tile1.prototype.frame = 2;
// building the world
function buildMap(map) {
	// attach empty mc to hold all the tiles and char
	_root.attachMovie("empty", "tiles", ++d);
	// declare clip in the game object
	game.clip = _root.tiles;
	// get map dimensions
	var mapWidth = map[0].length;
	var mapHeight = map.length;
	// loop to place tiles on stage
	for (var i = 0; i<mapHeight; ++i) {
		for (var j = 0; j<mapWidth; ++j) {
			// name of new tile
			var name = "t_"+i+"_"+j;
			// make new tile object in the game
			game[name] = new game["Tile"+map[i][j]]();
			// attach tile mc and place it
			game.clip.attachMovie("tile", name, i*100+j*2);
			game.clip[name]._x = (j*game.tileW);
			game.clip[name]._y = (i*game.tileH);
			// send tile mc to correct frame
			game.clip[name].gotoAndStop(game[name].frame);
		}
	}
}
// make the map
buildMap(myMap);
stop();

And this is the result

2) Write the code according to your style

This is a very important step. Every coder has his own way to indent code, name variables, write comments and so on.

In this example, it’s easy to see Tony loves naming variables with capizalized names such as myVariableName. I don’t like any uppercase char but I love underscores, so I would name the same variable as my_variable_name.

Question: Capitalize or underscore?
Answer: The one you are used to deal with

When working on someone’s else code, remember to edit it according to your rules, for a better readability. If the code is written in a language you don’t know, rename the variables once you found out what they store, or you’ll have to waste time every time you find a variable called fine_gioco when you should have named it as game_over

This is the same code as before, just written according to my rules

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
level_map = new Array();
level_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
level_map[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
level_map[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
level_map[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
level_map[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
level_map[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
level_map[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
level_map[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
game = {tile_width:32, tile_height:32,map_width:16,map_height:8};
game.tile_0 = function() {
};
game.tile_0.prototype.walkable = true;
game.tile_0.prototype.frame = 1;
game.tile_1 = function() {
};
game.tile_1.prototype.walkable = false;
game.tile_1.prototype.frame = 2;
build_map(level_map);
function build_map(map) {
	_root.attachMovie("empty", "tiles", ++d);
	game.clip = _root.tiles;
	for (var i = 0; i<game.map_height; ++i) {
		for (var j = 0; j<game.map_width; ++j) {
			var name = "t_"+i+"_"+j;
			game[name] = new game["tile_"+map[i][j]]();
			game.clip.attachMovie("tile", name, i*100+j*2,{_x:(j*game.tile_width),_y:(i*game.tile_height)});
			game.clip[name].gotoAndStop(game[name].frame);
		}
	}
}

Now, I can easily read it

3) Add something new

At this time, my game would look like the million games created from Tony’s tutorial.

It’s time to change the graphics and add some new features.

In my case, I’ll add a “grass” floor to the top of solid platforms. Now the “grass” is only a green line, but I am going to improve it a lot more during next steps of this tutorial

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
level_map = new Array();
level_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
level_map[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
level_map[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
level_map[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
level_map[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
level_map[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
level_map[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
level_map[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
game = {tile_width:32, tile_height:32, map_width:16, map_height:8};
game.tile_0 = function() {
};
game.tile_0.prototype.walkable = true;
game.tile_0.prototype.frame = 1;
game.tile_1 = function() {
};
game.tile_1.prototype.walkable = false;
game.tile_1.prototype.frame = 2;
build_map(level_map);
function build_map(map) {
	_root.attachMovie("empty", "tiles", ++d);
	game.clip = _root.tiles;
	for (var i = 0; i<game.map_height; ++i) {
		for (var j = 0; j<game.map_width; ++j) {
			var name = "t_"+i+"_"+j;
			game[name] = new game["tile_"+map[i][j]]();
			game.clip.attachMovie("tile", name, i*100+j*2, {_x:(j*game.tile_width), _y:(i*game.tile_height)});
			game.clip[name].gotoAndStop(game[name].frame);
			if ((map[i][j] != 0) and (map[i-1][j] == 0)) {
				game.clip.attachMovie("floor", "floor_"+(i*100+j*2)*5, (i*100+j*2)*5, {_x:(j*game.tile_width), _y:(i*game.tile_height)});
			}
		}
	}
}

Now the game looks different than the original tutorial.

During next steps, we’ll learn how to keep on using Tony’s tutorials to make a game that is only based upon his ideas, with fancy graphics and gameplay.

Download the sources and change something, should you make something interesting I would be happy to publish it here.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (11 votes, average: 3.91 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. BIVB

    on June 4, 2008 at 2:31 pm

    The game “tankbuster” (see my website) is based upon your artillery game tutorial, only I changed quite some stuff… Though, the cannonball and the canon are still there :)
    I hope you like it

  2. Keiran

    on June 4, 2008 at 2:37 pm

    GO EMANUELE!

    another great leap forward for flash games

  3. limpeh

    on June 4, 2008 at 3:14 pm

    Another good and useful article as usual. Looking forward to the 2nd part of this tutorial.

  4. Jerry

    on June 4, 2008 at 4:18 pm

    Another great tutorial and it is sad that you had to make this series.

  5. Scarybug

    on June 4, 2008 at 4:39 pm

    Good on you, man. But if you make an actual game out of this tutorial, won’t someone just publish that game as their own? =P

  6. Jack Hopkins

    on June 4, 2008 at 6:43 pm

    Take THAT stolen games!

  7. Grifo

    on June 4, 2008 at 8:18 pm

    As long as there are people making quality games, there will be little room for tutorials-with-game-names.

  8. Questo

    on June 4, 2008 at 10:41 pm

    how tue I absolutely hate when emanuele comes out with a game creation tutorial and the next day the source code or maybe a slightly modified souce code is out the next day. at I at least try to tweek the code and add totaly new aspectsto it for example I am still trying to make his wOne tutorial (thats Create a game like line rider orothers a different aproach for the people who didn’t recognize it for what it was) into somewhat of a platformer like sonic the hedgehog by adding a character inside and making him face the direction the ball goes in. By the way emanuele please include animation states so the clones look like decent playable games.

  9. tarzahn

    on June 4, 2008 at 11:46 pm

    yeah, emanuele, thanks to you stupid kids spam the internet with trash flash games. But i dont think this tutorial will help, because they just don´t know programming good enough to create their own thing.
    i mean your tutorials are a good thing but maybe you shouldnt post enough code for having a “real” game but only discuss algorithms, i dont know, its just sad ;)

  10. Xodus

    on June 5, 2008 at 4:50 am

    I hope everyone reads this tutorial!

  11. Frozenhaddock

    on June 5, 2008 at 8:14 am

    Something born from the forum perchance?

    http://www.triquitips.com/viewtopic.php?f=25&t=394

    Important for every new game developer, source files are there to learn from, not steal!

  12. Doomed_blondie1

    on June 5, 2008 at 11:35 am

    thx emanuele
    it really helped
    im not a great programmer and i love how you showed how to go from one game style to another thx a whole lot

  13. Scarybug

    on June 5, 2008 at 8:29 pm

    We were talking about it in the FlashGameLicense forum too ^_^

  14. Web-Game Magazine - the best free action/adventure web games and casual games, reviewed daily » Blog Archive » Create a Flash game like Deflection

    on July 11, 2008 at 7:05 pm

    [...] Moreover, this is another good example about how to use a Flash game tutorial to make your own game. [...]

  15. yeehhaa

    on August 14, 2008 at 2:37 am

    shut up you can make ace games from tutorials…
    And any way , i see youve not managed to get past the data block command yet .. guess your not capable of placing collion clips on the screen, your going about it the hard way.

  16. BlaXpirit

    on September 10, 2008 at 8:23 pm

    I’m a kid but i’m also a good programmer (mostly C++).
    This tutorial didn’t help me because it isn’t actually a tutorial (tutorial is something for beginners). I’m beginner in Flash and ActionScript

  17. Understanding pixels and meters with Box2D and how to select an object with mouse - part 1 : Emanuele Feronato

    on November 16, 2008 at 12:36 am

    [...] I modified the HelloWorld example in my own way in order to have some 90×90 ox sided crates (texture by http://www.reallyreallygoodthings.com/) I [...]

  18. nar

    on July 1, 2009 at 2:59 am

    You’d have to be retarded to just steal one of your tuts and just post it as a game. your tutorials are great for looking at how you would go about for making a game. People just have to understand that they would actually have to learn some coding to be able to do it properly. : ) also learning some AS then read these tutorials would be alot better i guess. ;)

  19. TH

    on March 11, 2011 at 10:23 pm

    I agree. I like his tutorials, but i’m still confused on all of this, is it copy and pasting then editting to your own fit?