Forum Topic: As: Tile Based Game Development Map

(5,239 views • 27 replies)

This topic is 1 page long.

<< < > >>
None

Inglor

Reply To Post Reply & Quote

Posted at: 7/2/05 03:33 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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


None

Galactic-Shit-Head

Reply To Post Reply & Quote

Posted at: 7/2/05 03:36 PM

Galactic-Shit-Head NEUTRAL LEVEL 03

Sign-Up: 06/30/05

Posts: 201

Very, very nice inglor.


None

Rustygames

Reply To Post Reply & Quote

Posted at: 7/2/05 03:36 PM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,662

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


None

Nemo

Reply To Post Reply & Quote

Posted at: 7/2/05 03:47 PM

Nemo LIGHT LEVEL 34

Sign-Up: 06/13/03

Posts: 1,895

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!


None

Xelius

Reply To Post Reply & Quote

Posted at: 7/2/05 05:04 PM

Xelius EVIL LEVEL 21

Sign-Up: 01/07/05

Posts: 381

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


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/2/05 05:05 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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 ;)


Angry

Thomas

Reply To Post Reply & Quote

Posted at: 7/2/05 05:23 PM

Thomas LIGHT LEVEL 13

Sign-Up: 02/14/05

Posts: 2,833

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


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/2/05 05:24 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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.


None

Toast

Reply To Post Reply & Quote

Posted at: 7/2/05 05:29 PM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,918

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.


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/2/05 05:34 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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?


None

Nemo

Reply To Post Reply & Quote

Posted at: 7/2/05 06:20 PM

Nemo LIGHT LEVEL 34

Sign-Up: 06/13/03

Posts: 1,895

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.


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/2/05 06:22 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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 ;)


None

Nemo

Reply To Post Reply & Quote

Posted at: 7/2/05 06:27 PM

Nemo LIGHT LEVEL 34

Sign-Up: 06/13/03

Posts: 1,895

Thanks Inglor. Big help :-P


None

Khao

Reply To Post Reply & Quote

Posted at: 7/7/05 02:25 AM

Khao EVIL LEVEL 19

Sign-Up: 09/20/03

Posts: 2,765

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


Happy

mb3

Reply To Post Reply & Quote

Posted at: 1/14/06 04:09 AM

mb3 DARK LEVEL 11

Sign-Up: 05/20/05

Posts: 71

thanks man i realy needed this tutorial!! =)

Mail me, or something.
"Lassie!"
"Bark! Bark, bark!"


None

Hoeloe

Reply To Post Reply & Quote

Posted at: 7/1/06 01:22 PM

Hoeloe LIGHT LEVEL 28

Sign-Up: 04/29/04

Posts: 5,014

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

Sex!
------------------------------
Super Nuke Bros. Melee, the web's no. 1 awaited Super Smash Tribute Game!

BBS Signature

None

BUDD-SMOKE-ER

Reply To Post Reply & Quote

Posted at: 9/2/06 11:55 AM

BUDD-SMOKE-ER NEUTRAL LEVEL 04

Sign-Up: 09/29/05

Posts: 91

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


None

DanWandin

Reply To Post Reply & Quote

Posted at: 10/23/06 12:08 PM

DanWandin DARK LEVEL 17

Sign-Up: 01/09/05

Posts: 722

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

BBS Signature

None

ChoosenStar

Reply To Post Reply & Quote

Posted at: 1/28/07 01:46 AM

ChoosenStar EVIL LEVEL 08

Sign-Up: 12/25/06

Posts: 709

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 .....


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 1/28/07 08:12 AM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,318

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

Some times my "L" key decides not to work.


None

ImpotentBoy2

Reply To Post Reply & Quote

Posted at: 1/28/07 08:13 AM

ImpotentBoy2 LIGHT LEVEL 18

Sign-Up: 04/01/03

Posts: 5,318

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

Some times my "L" key decides not to work.


None

Wilio

Reply To Post Reply & Quote

Posted at: 1/28/07 08:47 AM

Wilio FAB LEVEL 11

Sign-Up: 11/10/03

Posts: 201

Not working =( Only a blank screen.


None

sniffy-gerbil

Reply To Post Reply & Quote

Posted at: 3/18/07 08:21 AM

sniffy-gerbil NEUTRAL LEVEL 08

Sign-Up: 04/14/06

Posts: 166

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.


None

Vorlek

Reply To Post Reply & Quote

Posted at: 3/18/07 08:45 AM

Vorlek LIGHT LEVEL 19

Sign-Up: 12/26/05

Posts: 300

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

BBS Signature

None

Skeik-Sprite

Reply To Post Reply & Quote

Posted at: 3/18/07 02:04 PM

Skeik-Sprite LIGHT LEVEL 15

Sign-Up: 06/19/05

Posts: 1,399

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.


None

StridBR

Reply To Post Reply & Quote

Posted at: 3/22/07 11:49 AM

StridBR NEUTRAL LEVEL 04

Sign-Up: 02/25/07

Posts: 19

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


None

StridBR

Reply To Post Reply & Quote

Posted at: 3/22/07 11:57 AM

StridBR NEUTRAL LEVEL 04

Sign-Up: 02/25/07

Posts: 19

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

two layers of tiles??


None

LeechmasterB

Reply To Post Reply & Quote

Posted at: 3/22/07 12:06 PM

LeechmasterB EVIL LEVEL 16

Sign-Up: 04/01/05

Posts: 934


All times are Eastern Standard Time (GMT -5) | Current Time: 10:48 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!