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

ACTIONSCRIPT:
  1. fscommand("allowscale", false);
  2. fscommand("allowscale", false);
  3. // our map is 2-dimensional array
  4. myMap = new Array()
  5. myMap[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  6. myMap[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
  7. myMap[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
  8. myMap[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
  9. myMap[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
  10. myMap[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
  11. myMap[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
  12. myMap[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  13. // declare game object that holds info
  14. game = {tileW:32, tileH:32};
  15. // walkable tile
  16. game.Tile0 = function() {
  17. };
  18. game.Tile0.prototype.walkable = true;
  19. game.Tile0.prototype.frame = 1;
  20. // wall tile
  21. game.Tile1 = function() {
  22. };
  23. game.Tile1.prototype.walkable = false;
  24. game.Tile1.prototype.frame = 2;
  25. // building the world
  26. function buildMap(map) {
  27.     // attach empty mc to hold all the tiles and char
  28.     _root.attachMovie("empty", "tiles", ++d);
  29.     // declare clip in the game object
  30.     game.clip = _root.tiles;
  31.     // get map dimensions
  32.     var mapWidth = map[0].length;
  33.     var mapHeight = map.length;
  34.     // loop to place tiles on stage
  35.     for (var i = 0; i<mapHeight; ++i) {
  36.         for (var j = 0; j<mapWidth; ++j) {
  37.             // name of new tile
  38.             var name = "t_"+i+"_"+j;
  39.             // make new tile object in the game
  40.             game[name] = new game["Tile"+map[i][j]]();
  41.             // attach tile mc and place it
  42.             game.clip.attachMovie("tile", name, i*100+j*2);
  43.             game.clip[name]._x = (j*game.tileW);
  44.             game.clip[name]._y = (i*game.tileH);
  45.             // send tile mc to correct frame
  46.             game.clip[name].gotoAndStop(game[name].frame);
  47.         }
  48.     }
  49. }
  50. // make the map
  51. buildMap(myMap);
  52. 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

ACTIONSCRIPT:
  1. level_map = new Array();
  2. level_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  3. level_map[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
  4. level_map[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
  5. level_map[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
  6. level_map[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
  7. level_map[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
  8. level_map[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
  9. level_map[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  10. game = {tile_width:32, tile_height:32,map_width:16,map_height:8};
  11. game.tile_0 = function() {
  12. };
  13. game.tile_0.prototype.walkable = true;
  14. game.tile_0.prototype.frame = 1;
  15. game.tile_1 = function() {
  16. };
  17. game.tile_1.prototype.walkable = false;
  18. game.tile_1.prototype.frame = 2;
  19. build_map(level_map);
  20. function build_map(map) {
  21.     _root.attachMovie("empty", "tiles", ++d);
  22.     game.clip = _root.tiles;
  23.     for (var i = 0; i<game.map_height; ++i) {
  24.         for (var j = 0; j<game.map_width; ++j) {
  25.             var name = "t_"+i+"_"+j;
  26.             game[name] = new game["tile_"+map[i][j]]();
  27.             game.clip.attachMovie("tile", name, i*100+j*2,{_x:(j*game.tile_width),_y:(i*game.tile_height)});
  28.             game.clip[name].gotoAndStop(game[name].frame);
  29.         }
  30.     }
  31. }

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

ACTIONSCRIPT:
  1. level_map = new Array();
  2. level_map[0] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  3. level_map[1] = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1];
  4. level_map[2] = [1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1];
  5. level_map[3] = [1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1];
  6. level_map[4] = [1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1];
  7. level_map[5] = [1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1];
  8. level_map[6] = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1];
  9. level_map[7] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
  10. game = {tile_width:32, tile_height:32, map_width:16, map_height:8};
  11. game.tile_0 = function() {
  12. };
  13. game.tile_0.prototype.walkable = true;
  14. game.tile_0.prototype.frame = 1;
  15. game.tile_1 = function() {
  16. };
  17. game.tile_1.prototype.walkable = false;
  18. game.tile_1.prototype.frame = 2;
  19. build_map(level_map);
  20. function build_map(map) {
  21.     _root.attachMovie("empty", "tiles", ++d);
  22.     game.clip = _root.tiles;
  23.     for (var i = 0; i<game.map_height; ++i) {
  24.         for (var j = 0; j<game.map_width; ++j) {
  25.             var name = "t_"+i+"_"+j;
  26.             game[name] = new game["tile_"+map[i][j]]();
  27.             game.clip.attachMovie("tile", name, i*100+j*2, {_x:(j*game.tile_width), _y:(i*game.tile_height)});
  28.             game.clip[name].gotoAndStop(game[name].frame);
  29.             if ((map[i][j] != 0) and (map[i-1][j] == 0)) {
  30.                 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)});
  31.             }
  32.         }
  33.     }
  34. }

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 (7 votes, average: 3.29 out of 5)
Loading ... Loading ...
If you found this post useful, please consider a small donation.
» 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.

18 Responses to “How to use a Flash game tutorial to make your own game”

  1. BIVB on June 4th, 2008 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 4th, 2008 2:37 pm

    GO EMANUELE!

    another great leap forward for flash games

  3. limpeh on June 4th, 2008 3:14 pm

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

  4. Jerry on June 4th, 2008 4:18 pm

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

  5. Scarybug on June 4th, 2008 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 4th, 2008 6:43 pm

    Take THAT stolen games!

  7. Grifo on June 4th, 2008 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 4th, 2008 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 4th, 2008 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 5th, 2008 4:50 am

    I hope everyone reads this tutorial!

  11. Frozenhaddock on June 5th, 2008 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 5th, 2008 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 5th, 2008 8:29 pm

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

  14. yeehhaa on August 14th, 2008 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.

  15. BlaXpirit on September 10th, 2008 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

  16. nar on July 1st, 2009 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. ;)

Leave a Reply




Trackbacks

  1. 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. [...]

  2. Understanding pixels and meters with Box2D and how to select an object with mouse - part 1 : Emanuele Feronato on November 16th, 2008 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 [...]

Posts