2D Map Editor

BlitzPlus Forums/BlitzPlus Beginners Area/2D Map Editor

Ked(Posted 2007) [#1]
Can anyone tell me how to make a 2D map editor, or show me where I can find some tutorials?

Thanks


CS_TBL(Posted 2007) [#2]
A 2d map is a 2d array, it might be better to use a bank tho.

If a side of your map is bigger than that side of your screen (higher, wider, or both) then you can only display a part of your map, the size of your screen (or the size of the canvas you're using to display the map).

Here are typical variables you need:

- tilewidth
- tileheight
(for example 32x32 for a single tile)

- xtiles
- ytiles
(for example 16x12, giving you a 512x384 map using those 32x32 tiles)

- xoffset
- yoffset
(if the map is bigger than your display, then these vars store your position)

- currentx
- currenty
(the vars containing on which tile your mouse is at the moment, I typically have the visual coordinates in these, without adjusting them with xoffset and yoffset, so using the earlier mentioned variables, these vars would contain 0..15 and 0..11)

- currentlocation
(calced: (currentx+xoffset) + (currenty+yoffset)*xtiles), with this you know where to poke/peek in case you're using a bank)



Additionally there's a "palette" with tiles you can draw with, this could be represented in quite the same way as that map, with tilewidth and tileheight for the tiles, xtiles and ytiles for the dimension of the palette, and xoffset and yoffset when your palette is bigger than the canvas it's in. An extra variable is currenttile, which holds the selected tile in your palette. Make sure the map editor has access to this currenttile variable.

What you then do is check for the right events in the map editor. If you have the mousebutton down ($201), set a variable like 'LMD' to '1'. Next check for mousemovement ($203), if this is going in and LMD is '1', then you are drawing your currenttile into your map. To put this currenttile into your map use the map variables to put the value of currenttile at the right place.

That's roughly all to it really, basic map editors aren't that hard to do.


Labyrnth(Posted 2007) [#3]
I would like to see a tutorial on this please. Once i see it , i know i can do it.


Dabz(Posted 2007) [#4]
Well, 2D Map editors usually revolve around their associated engines (Apart from a few, such as Mappy), so really, there wont be too many tuts kicking around.

But I knocked up a cheap map editor with this code archive:-

http://www.syntaxbomb.com/forum/index.php?action=dlattach;topic=297.0;attach=86

That should give you the general idea.

Dabz


tonyg(Posted 2007) [#5]
You could get Learn to Program 2D Games in BlitzBasic which has a great chapter on creating a Map Editor.
You could also try these :
Good
Old
BlitzCoder


Labyrnth(Posted 2007) [#6]
Thank you Dabz, ill give it a look.

tonyg all 3 of those links are dead :(
* Wait a sec, man they load so slow it is not even funny.

Thank you guys, maybe i can gt a understanding about this now.


Ked(Posted 2007) [#7]
Thanks also.