Talking about Actionscript 2, Flash, Game development and Tutorials.
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
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
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
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
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.
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.