Tilebased games in Flash 5 – Part 3

Before we go into scrolling, I thought it would be a good idea to look into some tips and tricks that can be helpful.

The first thing is to NOT draw(draw means attach tiles) the map directly on the stage, instead draw it in an emtpy “container”-movieclip. Something like:

// first attach an empty movieclip
this.attachMovie("empty", "container", 0);

// then draw the map inside the container
for ( i = 0; i < mapHeight; ++i ) {
	for ( j = 0; j < mapWidth; ++j ) {
		this.container.attachMovie("tile", "t_"+i+"_"+j, ++d);
		this.container["t_"+i+"_"+j]._x = j*tileW;
		this.container["t_"+i+"_"+j]._y = i*tileH;

This makes it so much easier to move the map. If we were to make it scroll, just move the container instead of moving all the tiles individually.

For speed, don´t draw tiles that don´t contain anything or add something visualy. Like in Super mario for example, there is no point in drawing the blue sky tiles, it´s better to just have background movieclip and just change the color, depending on if it´s a black or blue background.

If you´re gonna make a scrollable game, use BITMAP-graphics for the tiles, one tile - one gif. Why? Because it´s soo much faster for flash to draw bitmaps on the screen, instead of complex vector-graphics. A little bug/feature you might run into is that when making a gif exactly, say 16x16 pixels, it will bleed in flash(look strange on the edges). This can be solved by making it 18x18 pixels instead, and then making a 1x1 pixel transparent frame around the actual 16x16 graphic.

Try to use LOW-quality when running the game, this can make a huge difference in some cases. You will of course have to adapt the graphics to work in low-quality, but that shouldn´t be a problem if you just use bitmaps.

Use as FEW enterFrame loops and frame loops as possible. When running many multiple loops it can get quite processor-intensive, thus making it run slow and sloppy. And we don´t want that, do we?

Try to make the game-engine as flexible as possible. Do it using OOP(Object Oriented Programming) if you know how to. This will make more complex games much, much easier to develop. In these tutorials we won´t make any OOP beacuse it can be a little harder to understand for some people and it might not be as straightforward as it is now. And I´m not really that good at it either :)

Some people think that they can make full-blown 3d-shooters in flash. I haven´t seen one single good example of this, and I think it´s just stupid to try :) Go with shockwave, wildtangent or something that´s suitible for that purpose, don´t beat a dead horse.

Come up with your own work-flow, something you feel comfortable with. Don´t just follow the bouncing ball and belive that I´m some sort of expert on this area. I can asure you I´m NOT. There are probably many better and faster ways to do games in flash, you find them!

Study classic game-titles on systems like: nintendo, c-64, spectrum, sega, atari, amiga, gameboy and so on. Try to make a basic engine of one you like. It´s usually much easier to do that, than coming up with a totally new idea, it works perfectly for learning purposes.

Don´t expect to learn everything within a week, it takes some time and it has to, that´s the whole concept of learning... It goes something like this:

progress = time*practice;

Ok, enough of this rant. On to the scrolling.


    Sorry, no Tweets were found.