Be a Supporter!

As: Tile Based Game Development Map

  • 7,201 Views
  • 27 Replies
New Topic Respond to this Topic
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
As: Tile Based Game Development Map Jul. 2nd, 2005 @ 03:33 PM Reply

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

Galactic-Shit-Head
Galactic-Shit-Head
  • Member since: Jun. 30, 2005
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 03:36 PM Reply

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 Jul. 2nd, 2005 @ 03:36 PM Reply

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

Nemo
Nemo
  • Member since: Jun. 13, 2003
  • Offline.
Forum Stats
Member
Level 34
Game Developer
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 03:47 PM Reply

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
Xelius
Xelius
  • Member since: Jan. 7, 2005
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 05:04 PM Reply

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 Jul. 2nd, 2005 @ 05:05 PM Reply

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

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 05:23 PM Reply

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 Jul. 2nd, 2005 @ 05:24 PM Reply

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 Jul. 2nd, 2005 @ 05:29 PM Reply

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
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 05:34 PM Reply

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 Jul. 2nd, 2005 @ 06:20 PM Reply

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
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Tile Based Game Development Map Jul. 2nd, 2005 @ 06:22 PM Reply

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 Jul. 2nd, 2005 @ 06:27 PM Reply

Thanks Inglor. Big help :-P


BBS Signature
Khao
Khao
  • Member since: Sep. 20, 2003
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As: Tile Based Game Development Map Jul. 7th, 2005 @ 02:25 AM Reply

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 Jan. 14th, 2006 @ 04:09 AM Reply

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 Jul. 1st, 2006 @ 01:22 PM Reply

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


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

BBS Signature
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 Sep. 2nd, 2006 @ 11:55 AM Reply

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 Oct. 23rd, 2006 @ 12:08 PM Reply

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 Jan. 28th, 2007 @ 01:46 AM Reply

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 Jan. 28th, 2007 @ 08:12 AM Reply

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 Jan. 28th, 2007 @ 08:13 AM Reply

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 Jan. 28th, 2007 @ 08:47 AM Reply

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 Mar. 18th, 2007 @ 08:21 AM Reply

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 Mar. 18th, 2007 @ 08:45 AM Reply

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
Supporter
Level 16
Game Developer
Response to As: Tile Based Game Development Map Mar. 18th, 2007 @ 02:04 PM Reply

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 Mar. 22nd, 2007 @ 11:49 AM Reply

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 Mar. 22nd, 2007 @ 11:57 AM Reply

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