00:00
00:00
Newgrounds Background Image Theme

Arnahan just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Tile Based Game Development Map

8,873 Views | 25 Replies
New Topic Respond to this Topic

The one AS thread to rule them all, AS: Main

This is 1/3 tile based tutorials,

Introduction-drawing the map
Advanced Uses- "hitTests" and movement
Isometrical Tile Based Games

What is this about

This tutorial is about Tile Based programming, it presumes knowledge of Arrays and is not that easy. However tile based programming is very useful, when compared to hitTest on maps the tile based check took 1/10 the time to accomplish, and it only occurs when the player moves.

What are tiles?

Tiles are basically costume made squares, instead of using flash's X,Y coordinate system you place object on tiles.

The first stage

the first stage is to actually create your level appearance, you need to decide how big your level is, I will use 10*10 here but you should use as much as you need,just remmember, in tile based programming the level generation itself takes time. I always name my objects levelN, like level1, level2, level3 and so on, tile based games work perfectly with xml for dynamic maps.

let's create an empty level 1, each level has 3 main elements (and a fourth one (hit area I rather not discuss yet), terrain (meaning the land) objects (meaning the trees, and impassable stuff) and enemies (meaning moving objects)

first let's create the terrain
level1.terrain=new Array(new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0));

this is the terrain, right now empty, we repeat the same process with objects and enemies, now remmember 0 means empty, the numbers really mean WHAT YOU TELL THEM TO, let's show how,

create a new movieclip and linkage-name it "tile-m" on it's first frame draw a 30*30 scale grass, on it's second 30*30 ice, these are your two tiles for now
create another one and linkage-name it "tile-0" for now it'll also have 2 frames. the first one will be empty and draw a rock in the second one.

now 0 represents grass (on the terrain map) and 1 represents ice, if there was a third frame 2 would represent whatever you draw in it.

now we need to actually create the map, this is done by a nested loop:

if(_root.map==null){ _root.createEmptyMovieClip("map");}
for(i=0;i<10;i++){
for(j=0;j<10;j++){
_root.map.attachMovie("tile-m","tile"+i+"_"+j,i*30+j*3000);//the depth doesn't matter here
_root.map.attachMovie("tile-m","tilem"+i+"_"+j,i*30+j*3000);//the depth does matter here
_root.map["tilem"+i+"_"+j].swapDepths(this._y);//so objects don't override.
_root.map["tile"+i+"_"+j]._x=i*30;//since 30 is the width/height
_root.map["tile"+i+"_"+j]._y=j*30;
_root.map["tilem"+i+"_"+j]._x=i*30;
_root.map["tilem"+i+"_"+j]._y=j*30;
}
}

there you have created a map based on the 2d array ;) congrats, about actually using it, on the next chapter, ask any questions on the tutorial here

Response to As: Tile Based Game Development Map 2005-07-02 15:36:15


Very, very nice inglor.

Response to As: Tile Based Game Development Map 2005-07-02 15:36:35


At 7/2/05 03:33 PM, Inglor wrote: Neat tutorial

Cool. This AS: thing is really going to help people as well as making alot less "n00by" posts. Oh yeah and of topic for a second.
1) have you blocked me on msn?
2) I meant ._parents the other day like in AS not parents as in birth


- Matt, Rustyarcade.com

Response to As: Tile Based Game Development Map 2005-07-02 15:47:45


This is a really cool tutorial. I was thinking about using a system like this to make the next game I am going to make. This will be really helpful. Nice work!


BBS Signature

Response to As: Tile Based Game Development Map 2005-07-02 17:04:01


For further reading, I can recommend Tile Based Games written by TONYPA.

Response to As: Tile Based Game Development Map 2005-07-02 17:05:52


At 7/2/05 03:47 PM, Atomic_Sponge wrote: This is a really cool tutorial. I was thinking about using a system like this to make the next game I am going to make. This will be really helpful. Nice work!

feel free to ask any question that pops into your head ;)

Response to As: Tile Based Game Development Map 2005-07-02 17:23:01


I'm thinking that maybe you copied most of this stuff from Tonypa's tutorial.


wat

Response to As: Tile Based Game Development Map 2005-07-02 17:24:27


I'm thinking I never knew of such a tutorial, and I just wrote this all by myself, I also think you should accuse me less, especially without anything solid or/and true to back you up.

Response to As: Tile Based Game Development Map 2005-07-02 17:29:33


At 7/2/05 05:23 PM, Thomas2005 wrote: I'm thinking that maybe you copied most of this stuff from Tonypa's tutorial.

Even if he DID copy from that tutorial,so what?As long as it helps people,I don't see where the problem is.


BBS Signature

Response to As: Tile Based Game Development Map 2005-07-02 17:34:16


At 7/2/05 05:29 PM, -Toast- wrote: Even if he DID copy from that tutorial,so what?As long as it helps people,I don't see where the problem is.

the problam is me being accused of something I didn't commit based on nothing?

Response to As: Tile Based Game Development Map 2005-07-02 18:20:15


Actually I have a few quick questions:

1. In the part with if(_root.map==null), is that just testing to see if an object named "map" is not created? I've never used null in any of my scripting before.

2. Not completely on subject, but is "nul"l anything similar to "void" or "undefined"?

3. Would it be possible to make a loading bar that displays the progress of map creation by having a variable increase in each of the loops and finding the percentage out of a total?

Thanks for any responses.


BBS Signature

Response to As: Tile Based Game Development Map 2005-07-02 18:22:54


At 7/2/05 06:20 PM, Atomic_Sponge wrote: Actually I have a few quick questions:

coo

1. In the part with if(_root.map==null), is that just testing to see if an object named "map" is not created? I've never used null in any of my scripting before.

null is "nothing"

2. Not completely on subject, but is "nul"l anything similar to "void" or "undefined"?

yes, in flash null===undefined, they are the same thing in flash

3. Would it be possible to make a loading bar that displays the progress of map creation by having a variable increase in each of the loops and finding the percentage out of a total?

yea, I've done it (loading text), but it can't have precentage since there is no way to update it after each time since it's in a for loop.

Thanks for any responses.

anytime man ;)

Response to As: Tile Based Game Development Map 2005-07-02 18:27:38


Thanks Inglor. Big help :-P


BBS Signature

Response to As: Tile Based Game Development Map 2006-01-14 04:09:42


thanks man i realy needed this tutorial!! =)


|

Response to As: Tile Based Game Development Map 2006-07-01 13:22:15


it didn't work :( i just got a blank screen


BBS Signature

Response to As: Tile Based Game Development Map 2006-09-02 11:55:27


ur a liar u copied it from another site
its even wrote out the same
why lie to make yourself look good
taking someone elses credit

Response to As: Tile Based Game Development Map 2007-01-28 01:46:13


At 9/2/06 11:55 AM, BUDD-SMOKE-ER wrote: ur a liar u copied it from another site
its even wrote out the same
why lie to make yourself look good
taking someone elses credit

you have no proof of anything you fucker shut up even if he did at least he helped people
i dont see anything helpful youve done .....

Response to As: Tile Based Game Development Map 2007-01-28 08:12:04


At 1/28/07 01:46 AM, Wishing-Sart-1993 wrote:
At 9/2/06 11:55 AM, BUDD-SMOKE-ER wrote: ur a liar u copied it from another site
its even wrote out the same
why lie to make yourself look good
taking someone elses credit
you have no proof of anything you fucker shut up even if he did at least he helped people
i dont see anything helpful youve done .....

i believe he shut up more then a year ago. theres no way he'll ever read your message

Response to As: Tile Based Game Development Map 2007-01-28 08:13:41


At 1/28/07 08:12 AM, ImpotentBoy2 wrote: i believe he shut up more then a year ago.

whoops misread date. 4 months. point still stands

Response to As: Tile Based Game Development Map 2007-01-28 08:47:16


Not working =( Only a blank screen.

Response to As: Tile Based Game Development Map 2007-03-18 08:21:56


Try creating a level1 instance movie clip, it might work. Make sure the movie clip is as big as the stage. I'm no AS expert though so I don't if it'll work or not.

Response to As: Tile Based Game Development Map 2007-03-18 08:45:50


Cool, i used to use tiles but i found they wasted too much time. I found a whole website with loads of tutorials on it. Just search tilebased games on google.

Response to As: Tile Based Game Development Map 2007-03-18 14:04:41


At 3/18/07 08:21 AM, sniffy-gerbil wrote: Try creating a level1 instance movie clip, it might work. Make sure the movie clip is as big as the stage. I'm no AS expert though so I don't if it'll work or not.

someone explain to me all that level0 and level1 stuff :( I dont get it.

Response to As: Tile Based Game Development Map 2007-03-22 11:49:24


these were changes i need to get code running:

var terrain: Array =new Array(
new Array(2,0,2,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,2,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,2,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,0),
new Array(0,0,2,0,0,0,0,0,0,0),
new Array(0,0,0,0,0,0,2,0,0,0),
new Array(0,0,0,0,0,0,0,0,0,2));

trace(terrain[2][7])

if(_root.map==null){ _root.createEmptyMovieClip("map", this.getNextHighestDepth());}
for(i=0;i<10;i++){
for(j=0;j<10;j++){
_root.map.attachMovie("tile-m","tile"+i+"_"+j ,i*30+j*3000);//the depth doesn't matter here
_root.map.attachMovie("tile-m","tilem"+i+"_"+
j,i*30+j*3000);//the depth does matter here
_root.map["tilem"+i+"_"+j].swapDepths(this._y );//so objects don't override.
_root.map["tile"+i+"_"+j]._x=i*30;//since 30 is the width/height
_root.map["tile"+i+"_"+j]._y=j*30;
_root.map["tilem"+i+"_"+j]._x=i*30;
_root.map["tilem"+i+"_"+j]._y=j*30;
_root.map["tilem"+i+"_"+j].gotoAndStop(terrai n[j][i])
}
}

but i still doesnt understand what are those tile-0 about

Response to As: Tile Based Game Development Map 2007-03-22 11:57:24


also, why do we have to attach tile's e tilem's?

two layers of tiles??

Response to As: Tile Based Game Development Map 2007-03-22 12:06:56