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.

First of all, I don't have much experience on game development but I do have experience on development. I do know how to make a map, but I don't know if my solution is a normal or a hacky solution. I don't want to waste my time coding things, and realise they're utterly crap and lose my motivation.


Let's imagine the following map. (2D - top view - A square)

X: 0 to 500 Y: 0 to 500

My character currently stands at X:250,Y:400, somewhere near center of 100px above bottom and I can control him with my keyboard buttons. LEFT button does X--, UP button does Y-- etc.

This one is kid's play.

I'm asking this because I know there are some engines that automate this task. For example, games like Diablo 3 uses an engine. You can pretty much drag drop a rock to map, and it is automatically being placed here - making player unable to pass through/detect the collision. But what the engine exactly does in the background? Generates a map like mine, places a rock at the center, and checks it like:

unmovableObjects = array('50,50'); //we placed a rock at 50,50 location

if(Map.hasUnmovableObject(CurrentPlayerX, CurrentPlayerY))
{
     //unable to move
}
else
{
     //able to move
}

My question is: Is this how 2D/Isometric maps are being generated or there is a different and more complex logic behind them?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

One old style navi-map combines immovability/navigability with object ID - generally was a one byte bit field per map coordinate, thus a matrix (well, an array) of bytes:

0x00 = empty space
0x80 = wall
0xff = user character
0x01 = terrain/object 1
0x81 = impassable/immovable 1

etc. even more likely for character-based "graphical" maps, the actual ASCII code of the character to be displayed in each tile would be the object ID.

Nowadays, folks don't much care about how much memory these data structures use, nor how efficient the logic is, so you end up with matrices (or arrays of arrays) of objects (or structs) that have properties (fields) for every possible attribute, and methods (function pointers) for all "standard"/common actions on or by that object.

share|improve this answer
    
So if I understood correct, each pixel is having an array with attributes set? Like: 1,1 = array('GRASS', 'MOVEABLE', 'DEFAULT_SPEED'); 1,2 = array('SWAMP', 'MOVEABLE', 'HALF_SPEED'); So 1,1 would mean you're on grass and moving at default speed, if you move 1,2 you would be on swamp and your movement speed is reduced by half. This is what you meant? I'm usually related to web development so don't know much about bytes, ascii codes and such. –  Icarus Cocksson Dec 20 '12 at 1:08
    
Yes, that would be a likely "modern" solution - a fairly workable and flexible for smaller maps and minimal interaction and/or dynamic activity. ("Dynamic activity" would be changes happening independently from the user/player character movement/actions) –  Richard Arnold Mead Dec 20 '12 at 23:41
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.