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 512x256 movie, so I had to add some tiles to the map
-
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
-
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
-
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.
Tell me what do you think about this post. I'll write better and better entries.
They can be easily customized to meet the unique requirements of your project.
16 Responses to “How to use a Flash game tutorial to make your own game”
Leave a Reply
Trackbacks
-
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 11th, 2008 7:05 pm
[...] Moreover, this is another good example about how to use a Flash game tutorial to make your own game. [...]


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
GO EMANUELE!
another great leap forward for flash games
Another good and useful article as usual. Looking forward to the 2nd part of this tutorial.
Another great tutorial and it is sad that you had to make this series.
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
Take THAT stolen games!
As long as there are people making quality games, there will be little room for tutorials-with-game-names.
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.
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 ;)
I hope everyone reads this tutorial!
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!
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
We were talking about it in the FlashGameLicense forum too ^_^
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.
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