Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been trying to understand cellbased maps and how they work, i have googled alot but can't seem to find any explanation for it.

With cell based maps i mean the ones where you do height and everything like walls roof floor in each cell. If possible i would appreciate an explanation from a Javascript perspective, but only a theoretical explanation can do.

So why do we use them? how do they work? Is it just like a normal array with more information?

share|improve this question
    
Sorry, the internet is a bit dry on the topic, but if you could tell me exactly what a cell based map is I'll tell you how it works, why and how to use it etc. –  eBusiness Mar 4 '12 at 17:04
    
It wouldn't be just a fancy word for completely plain and ordinary array maps? –  eBusiness Mar 4 '12 at 17:11
    
Actually, why do you ask? It's just a fancy word after all, it doesn't even matter whether the maps you make fit the description or not, as long as they do the job you want them to. –  eBusiness Mar 4 '12 at 17:15
    
The cellbased maps as i understand so far is where each "node" is a cell with information about everyting in/on that node such as walls, floor, roof, and items. Seems to be the way to do tilebased maps, but i can't find any good documentation about it. No matter how i formulate the query on google. –  hustlerinc Mar 4 '12 at 17:42
    
Well, just look up tile maps, no reason getting worked up about this specific word. –  eBusiness Mar 4 '12 at 17:55
add comment

1 Answer

up vote 6 down vote accepted

Most commonly tile based games mix two types of data to make the game world.

  1. A tile grid with information that every tile needs to have like texturing, accessibility, height, two of the four adjacent possible walls and depending on the game perhaps some other stuff.

  2. All the stuff that can move, or is complex to represent. This is usually made as individual objects containing all their own properties, including position coordinates. You store these objects on one or multiple lists. Often it will be advantageous to have links from the tiles to the objects occupying it.

A small sketch:

grid=[]
for(a=0;a<100;a++){
    grid[a]=[]
    for(b=0;b<100;b++){
        grid[a][b]={} //one object for every tile, stuff in all the info you need
    }
}
character={}
character.x=3
character.y=4
misc=[] //list of case 2 objects
misc[misc.length]=character
grid[character.x][character.y].occupant=character //backwards reference
share|improve this answer
    
Nice just what i was looking for. –  hustlerinc Mar 4 '12 at 21:10
    
Remember to mark it as 'answered' –  Aralox Mar 5 '12 at 11:00
    
And do remember, it's just one of many possible setups, needs vary from game to game, it won't fit everything. –  eBusiness Mar 5 '12 at 14:21
    
Yeah but its a good enough start. :) thx –  hustlerinc Mar 5 '12 at 20:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.