## As: Tile Based Game Development Map

• 7,249 Views
• 27 Replies
Inglor
Inglor
• Member since: Jan. 26, 2003
• Offline.
Forum Stats
Member
Level 17
Blank Slate
As: Tile Based Game Development Map 2005-07-02 15:33:58

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

This is 1/3 tile based tutorials,

Introduction-drawing the map
Isometrical Tile Based Games

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

• Member since: Jun. 30, 2005
• Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to As: Tile Based Game Development Map 2005-07-02 15:36:15

Very, very nice inglor.

Rustygames
Rustygames
• Member since: May. 7, 2005
• Offline.
Forum Stats
Member
Level 19
Programmer
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

Nemo
Nemo
• Member since: Jun. 13, 2003
• Offline.
Forum Stats
Member
Level 34
Game Developer
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!

Xelius
Xelius
• Member since: Jan. 7, 2005
• Offline.
Forum Stats
Member
Level 21
Blank Slate
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.

Inglor
Inglor
• Member since: Jan. 26, 2003
• Offline.
Forum Stats
Member
Level 17
Blank Slate
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!

Thomas
Thomas
• Member since: Feb. 14, 2005
• Offline.
Forum Stats
Member
Level 13
Musician
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
a compessor wil raise the volume while lowering the db - chronamut

Inglor
Inglor
• Member since: Jan. 26, 2003
• Offline.
Forum Stats
Member
Level 17
Blank Slate
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.

Toast
Toast
• Member since: Apr. 2, 2005
• Offline.
Forum Stats
Member
Level 09
Blank Slate
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.

Inglor
Inglor
• Member since: Jan. 26, 2003
• Offline.
Forum Stats
Member
Level 17
Blank Slate
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?

Nemo
Nemo
• Member since: Jun. 13, 2003
• Offline.
Forum Stats
Member
Level 34
Game Developer
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.

Inglor
Inglor
• Member since: Jan. 26, 2003
• Offline.
Forum Stats
Member
Level 17
Blank Slate
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 ;)

Nemo
Nemo
• Member since: Jun. 13, 2003
• Offline.
Forum Stats
Member
Level 34
Game Developer
Response to As: Tile Based Game Development Map 2005-07-02 18:27:38

Thanks Inglor. Big help :-P

Khao
Khao
• Member since: Sep. 20, 2003
• Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As: Tile Based Game Development Map 2005-07-07 02:25:05

Hey Inglor here is a tutorial that shows how to make a tile-based map for RPG games! It awesome (your tut is too hehe)

http://www.kirupa.co../rpgprogramming6.htm

mb3
mb3
• Member since: May. 20, 2005
• Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to As: Tile Based Game Development Map 2006-01-14 04:09:42

thanks man i realy needed this tutorial!! =)

|

Hoeloe
Hoeloe
• Member since: Apr. 29, 2004
• Offline.
Forum Stats
Member
Level 37
Game Developer
Response to As: Tile Based Game Development Map 2006-07-01 13:22:15

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

Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BUDD-SMOKE-ER
BUDD-SMOKE-ER
• Member since: Sep. 29, 2005
• Offline.
Forum Stats
Member
Level 04
Blank Slate
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

DanWandin
DanWandin
• Member since: Jan. 9, 2005
• Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to As: Tile Based Game Development Map 2006-10-23 12:08:40

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

I believe that Inglor is a highly respected AS'er on NG, I think somebody's jealous!
It's true, people are accusing him based on nothing.

I <3 U INGLOR!!

Thanks for the awesome tut, I never thought I'd ever get into making flash rpg's, they looked too complex, but with a little understanding, from your tut and all, its become alot simpler.

-Dan

Anal Nerve endings enable individuals to distinguish between flatus and feces, although loose stool can confuse the individual, occasionally resulting in accidental defecation

ChoosenStar
ChoosenStar
• Member since: Dec. 25, 2006
• Offline.
Forum Stats
Member
Level 08
Blank Slate
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 .....

GeoKureli
GeoKureli
• Member since: Apr. 1, 2003
• Offline.
Forum Stats
Supporter
Level 19
Game Developer
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

GeoKureli
GeoKureli
• Member since: Apr. 1, 2003
• Offline.
Forum Stats
Supporter
Level 19
Game Developer
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

Wilio
Wilio
• Member since: Nov. 10, 2003
• Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to As: Tile Based Game Development Map 2007-01-28 08:47:16

Not working =( Only a blank screen.

sniffy-gerbil
sniffy-gerbil
• Member since: Apr. 14, 2006
• Offline.
Forum Stats
Member
Level 08
Blank Slate
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.

Vorlek
Vorlek
• Member since: Dec. 26, 2005
• Offline.
Forum Stats
Member
Level 25
Audiophile
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.

Skeik-Sprite
Skeik-Sprite
• Member since: Jun. 19, 2005
• Offline.
Forum Stats
Member
Level 16
Game Developer
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.

StridBR
StridBR
• Member since: Feb. 25, 2007
• Offline.
Forum Stats
Member
Level 04
Blank Slate
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

StridBR
StridBR
• Member since: Feb. 25, 2007
• Offline.
Forum Stats
Member
Level 04
Blank Slate
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??

LeechmasterB
LeechmasterB
• Member since: Apr. 1, 2005
• Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Tile Based Game Development Map 2007-03-22 12:06:56

http://www.tonypa.pri.ee/tbw/index.html