my tile map editor + gui

BlitzMax Forums/BlitzMax Beginners Area/my tile map editor + gui

Jesse(Posted 2010) [#1]
I have been working on putting together a tile map editor. it is at its early alpha stage. it has a few bugs but it's usable none the less.

features included:
graphical gui windows style:
re sizable movable windows
sliders
text input fields
lists
drop down menu
buttons
mulit windows


the tile map editor is basic and working:
creates maps any size and uses tiles between 4x4 to 128x128 narrow or wide, multiple layers limited to six. map size limited by ram.
undo and redo single tile or group.
multi group tile buffer storage and selection and removal.
Saves tilegrid and graphics to a single file and loads from a single file.

I am posting it in hopes I can get some help in solving bugs that I can't see. i am almost sure the file requester will crash in windows 7 and vista but I don't know for sure. I know it has a bug in the ability to read directories. if there is an old diskette drive, it will more than likely crash as it waits to read the disk drive. Also, I don't know for sure as I don't have one anymore. I have solved most of the problems I know off or know how to repair. I have one problem I don't know how to solve and thats the ability to peek at the devices with out it asking to insert a cd or a disk which is where it fails most of the time. the code for the drive's acces is from skin[3]ac and is in the code archives. any help is appreciated.

I don't know how well it will work in other systems. I am curious if this works in windows 7 or vista.


I am planning:
add the ability to paste a group of tiles (done)
add animated tiles
an object layer
scripting of objects if I can figure out how to implement it.

you can download the file from here:
windows:
http://www.filefront.com/17271981/tilemapeditorWip.zipmac
ppc:
http://www.filefront.com/16928161/tilemap-mac.zip


Xerra(Posted 2010) [#2]
Sorry, not running Windows Vista or 7 as i'm a die-hard Xp user. I can confirm that the map editor runs fine on my machine. I created a map, loaded and saved it with no problems. Don't know if that's much help, however :)


iprice(Posted 2010) [#3]
Seems to work fine in Windows 7. :)


Jesse(Posted 2010) [#4]
Xerra and iprice thank you for your time. I will keep working on this hopefully I can find most of the bugs.


hepcat(Posted 2010) [#5]
Jesse,

I have a vista machine and a mac. Your file isn't available anymore... or I would have tested it ;)


Jesse(Posted 2010) [#6]
thanks hepcat. I have been updating the file fixing bugs and integrating other options but I forgot to update the link. I have updated the link in the first post to reflect the current state. Thanks in advance for any input you can provide.


Volker(Posted 2010) [#7]
Works fine here under Windows 7 64 bit.
Except the error I get after starting because there
is no drive A. After clicking on continue two times the editor starts.


Jesse(Posted 2010) [#8]
thanks Volker! That error keeps bugging the s***t out of me. Aparently your Bios still has the floppy disk drives registered in it, that is why you get the error. I haven't been able to go around that problem. The program is made to run in full screen mode but if I do that it will lock the program, sense, it will not display the error window in full graphics mode. if anyone has any idea on how to solve that error please help. I am using skin3[ac] code that is in the code archives to get full access to the directory/drive system but it lacks the ability to look for available drives with out actually looking for content in them. thus the error. I posted this problem before but no one was able to help me, maybe this time around some one has a solution. hopping.


Xerra(Posted 2010) [#9]
I've been tinkering with your map editor again as I was thinking about doing some kind of scrolling based game after I finish what I'm doing.

How do I load up an image file of tiles seperately to start creating a map from them?

Is it possible to save the window positions when you save a map file so when it's loaded they appear where you left them?

The layer switching buttons are great but is it possible to have them colour highlighted or something when toggled so it's clearer which layer is active at the time?

The viewing window for the graphic tiles doesn't appear to have scroll bars so wont show all the tiles in the example map I have.

Other than that it's looking really good for something that's not finished. Good work, Jesse.


Jesse(Posted 2010) [#10]
thanks for trying it out Xerra. It is still in a "lets try to see if this works" stage. thanks for for bringing up things that I had not considered.

How do I load up an image file of tiles separately to start creating a map from them?


I have made it so that it only allow graphics to be loaded when first creating the map. When the new window is open you get to select the map size,tile size and which sprite image to use for tiles. you can type the image name directly, or you can look for it with the search button. It only takes Png, bmp and jpg files, The normal blitzmax files. The image file size has to follow the same rules as when loading animated images in BlitzMax. you can put the exact tile count if you know it or if you want to include all of the tiles in the sprite and you don't want to go through the process of counting the tiles you can put an exagerated number and it will load the number of tiles available only. Once the map is saved you don't need the sprites image file anymore as they get integrated in the map and will not need to be included separately.


Is it possible to save the window positions when you save a map file so when it's loaded they appear where you left them?


no, I had not considered that but good idea. I'll add it to the things to do.

The layer switching buttons are great but is it possible to have them colour highlighted or something when toggled so it's clearer which layer is active at the time?


I thing I need to make better buttons, they do have up and down state if you look carefully, problem is I made the buttons myself and my graphics skills are not that great. I will try as you say to see if that works better.

The viewing window for the graphic tiles doesn't appear to have scroll bars so wont show all the tiles in the example map I have.



I have not noticed anything wrong with it. The times I have tried it does create a scroll bar and it does show all of the tiles but I'll keep on testing maybe I can figure out what went wrong.

I want to add a a few things like:
the ability to resize the map
layer shifting
stamp a group of tiles
animations
create an editor state file. (new)

thanks Again Xerra.


Xerra(Posted 2010) [#11]
No problem at all. I didn't think to test with a new map creation but I just tried it and it's fine. I also got the tiles scroll bars appearing when I loaded in another tile set so I guess I must have done something wrong before.

Curious as to one thing, however. What's the max size of a map you can have with the editor at the moment? I tried with a 1000 height, 32 width but it was only a screens worth in height still. Smaller setting on the height side would work but I don't have the file mapformat.rtf that the help window refers to in the version i'm using so I think it would be hit and miss doing trial and error to work it out myself :)

I do really like the editor as it stands, though, so i hope you keep up with it :-)


Jesse(Posted 2010) [#12]
Ops! another bug. I guess I have to work on fixing the scroller for maps wider or taller than the size of the scroller(tile per pixel in scroller). I guess for now the max map size is 615x555. until I can figure out how to solve that issue.

[edit] scroller appears to be working correctly now, I will post update soon [/edit]

I didn't want to post the format sense I am sure it will change a couple of times before I am done. Here it is for the current state of the program.
				TILE MAP FORMAT
read variables in THIS ORDER
open map file
bytes	 		type	 		description
5			string			"JPMAP"  identifies the map type
1			byte			tile size width max  128
1			byte			tile set Height max 128
4			int			starting tile to load
4			int			number Of Tiles to Load
4			int			map width
4			int			map height
4			int			number of layers
4			int 			image size  (stored file size)
variable		bank			the actual sprites image in a bank
sprites image can be created like this:
local imagebank:tbank = New TBank
imagebank.resize(imageFileSize)
imagebank.read(mapFile,0,Image Size)
image = animImage(imagebank,tile size width,tile size height,first,count)
-------------------------------------map follow --------------------------------------------------------------
layer  = 0 until  number of layers
      read layer type  byte     ' 1 collision layer,  2 tile layer
      for  y = 0 until  map height
           for  x = 0 until map width
                  if layer type =  collision layer
                             read byte  to collision:byte[x,y] collsion layer
                   else
                          read short  to map:short[x,y,Layer] tile layer
                   endif
             next x
     next y
next leyer
close mapfile

you can load all of the layers in to the map array. The last layer to be saved is always the collision layer if it has one. just remember to load it as bytes.
I still need to figure out a way to compress large maps.


CS_TBL(Posted 2010) [#13]
I've made a mapeditor recently for a retrogame I'm doing. Over 2500 lines o'code. It includes a script editor for automatic (multiple) road connectors (draw with one tile and it picks the right road crossings and T-crossings) and random tiles (draw with one grass tile, and it paints all related tiles like grass, trees, rocks etc.). It includes a full featured tile editor to draw tiles, a palette editor (it's retro, so it's 16 colors out of 512), a few (fixed) layers to set flags and a few exporters. The only GUI object I made myself (apart from the mapviewer, tile manager and tile editor) was a menu with a few text options. For the rest it's just OS graphics.

It's not the first time I've made editors, and over the years I've found out the things that work and the things that don't work. Things that work are often the result of radical choices; an unconventional hotkey here, an unconventional menu there etc. Also, I've made quite a few games since 2005 (no blitz games but typically I made editors for them in blitz).

Things I have to say about your editor (so far):
- ditch the pulldown menu code. That's what the OS is for, and it does a way better job than yours..
- ditch the file requester, for the same reasons stated above
- ditch the scrollbar code, idem dito (do you realize that the white background looks like the foreground button to drag around?)
- I don't know how big my maps will be, so I don't want to have to choose that at the start. Rather I want to expand my map at either side when required
- meanwhile I've made it loop ad infinitum when trying to create a new project while there was an old one
- trade visual menus for hotkeys.
- I have the feeling that sooner or later you'll hit a brick wall when you are really about to make a game with it. The problem lies in having separate objects for map and collision. A programmer may ask you for another 3..4 layer types, meaning you'll have to update your whole code to include that in your drawing routines and event checks. My own map editor uses a tile type which contains an array. So, what's 'map' and 'collision' in your code is mapdata[x,y].data[0] and mapdata[x,y].data[1] in my code. With this I can step through all my layers with a simple for loop, and that's it.

But you gotta start somewhere.. :P and my first map editors were handy, in a way, but definitely not future proof and full o' one shot code. So, it'll come. In time, as I predict that your current efforts needs a few deep rooted design changes.


Jesse(Posted 2010) [#14]
Thanks for your opinion CS_TBL and I respect it even though I never asked for one. I posted it in hope I could get some help figuring out bugs.:

I am posting it in hopes I can get some help in solving bugs that I can't see. i am almost sure the file requester will crash in windows 7 and vista but I don't know for sure. I know it has a bug in the ability to read directories. if there is an old diskette drive, it will more than likely crash as it waits to read the disk drive. Also, I don't know for sure as I don't have one anymore. I have solved most of the problems I know off or know how to repair. I have one problem I don't know how to solve and thats the ability to peek at the devices with out it asking to insert a cd or a disk which is where it fails most of the time. the code for the drive's acces is from skin[e]ac and is in the code archives. any help is appreciated.


I am making this for my own benefit and use, and no, I am not about to change anything about it as per your suggestions. I own a copy Bmax gui but decided to go this route anyway as I would like to integrate this into a game and I marely want to learn to do stuff on my own.
I posted this file for help and if in the process someone finds it usefull then good else it is serving its purpose either way. I realize that it is not everybody's cup of tea and there are things i don't like about it either but I will change them as I am able to figure things out. I am trying to make it extremely flexible as I am progressing. I realize I can't think of all obstacles I will encouter but that will serve me as experience for future projects.

I hope you don't take this the wrong way as I do appreciate any comments any one makes but sometimes my decisions are not up for discusion and this is one of them.
by the way I would like to see your tile map editor if that is possible. Maybe it will give me some ideas to integrate into mines.


Jesse(Posted 2010) [#15]
if anybody cares about helping me test it, I have updated the editor:

fixed the scroller ( I think)
added group selector (left shift + left mouse button + mouse movement)
store selected group to buffer
added buffer window(buffer window scroller still not functional)- fixed
in progress:
delete selected
paste buffer

to do:
settings file
create objects layer(group tiles for movement, animation and characteristics)

executable in first post.


Xerra(Posted 2010) [#16]
Yup, i'll have another look, thanks Jesse. I'll update once i've given it a test run, mate.


Jaydubeww(Posted 2010) [#17]
This looks promising! Is it just for windows at the moment?


Jesse(Posted 2010) [#18]
Is it just for windows at the moment?

Yes, at the moment. The only thing that is limiting from compiling in other systems is the file requester which looks in other drives; the code is specific to windows. I might have to remove it and limit it to a single drive to create a Mac and Lenux executable.

[edit]
thanks Xerra forgot to acknowledge earlier


Shortwind(Posted 2010) [#19]
Hey, been testing and playing with your map editor. I've got a couple questions, and possibly a bug... First I would like to say I'm impressed with how you've progressed. You created the window code yourself? That's great. I like the "sun-mouse" option on the windows, it's nice not having to click to bring the window to the front.

How do I resize the windows? (Main map editor window, and tileset window...) I can't seem to resize any of the windows. :( (How do I resize the main window???)

Can we have more than one buffer for creating standard multiple tile "models"? Currently one buffer is great, but it would be awesome to be able to have many buffers, easily pickable from the buffer window. I also should be able to click on the buffer window "pre-build model" and have it automatically selected as the thing to paste in the map editor window. It would be great to also be able to save these "pre-built" "models" between sessions.

I can't get the keyboard controls to work. CTRL K, CTRL V, don't work in the editor window, I have to goto the edit menu to create and paste the buffer.

Finally, a request. This may not be appropriate for your project, or your intent with this editor, but I would like to see an expansion on the buffer, "model", concept. In other words, if I want to create a "model" for a complete tree, it would be nice to be able to build that tree, including collision area, and layer area (so a character can walk behind, or in front of the tree.) Also, I would like to be able to open a "work" window, where I build the prebuild "models", instead of having to do that in the main editing window. But maybe this is beyond the scope of your current project.

Maybe I'm stupid, but how do I use the collision layer??? I'm probably just missing something obvious, but I guess I'm used to being able to ctrl-right-click on a tile and bring up a window with properties on that tile, or group of tiles and set the collision property. (I suppose it would be nice to be able to set default properties in the tile window itself... but maybe I'm missing something....)

Also, what are your plans for "viewing the map???" I believe you should add an option to view the map in a selected resolution (full-screen), and have a "fake" character be able to navigate the level, for faux-pa testing.


:D


Jesse(Posted 2010) [#20]
@Shortwind, Thanks for the kind words and Thanks for testing it out.

You created the window code yourself?


yes 100% from my own ideas. I have been working on the Gui for over a year on and off. I did several versions before but I decided to stick with this one. I am not so sure I like the graphics. I will probably change to a different graphics set some time in the future or not. the Gui could definitely need some work but it's serving it's purpose as it is. It is also not event driven which 'might' change in the future.


How do I resize the windows? (Main map editor window, and tileset window...) I can't seem to resize any of the windows. :( (How do I resize the main window???)



the Gui has options just like the real windows:
it has close, minimize, and resize options which have to be set during creation. I have set the movable option only and that is why they can not be resized, minimized or closed. There are things about the resize options that still don't work and is another reason why I locked them to those options. I will start working on an options window so that they can be set during use and at start up. thats after I fix a couple of bugs that have been stressing me.


I can't get the keyboard controls to work. CTRL K, CTRL V, don't work in the editor window, I have to goto the edit menu to create and paste the buffer.



I haven't updated the file but I have fixed CTRL K, not CTRL V and is one of the bugs that's stressing me. It was supposed to be a simple integration "if lcontrol down and key_v hit then pastegroup= true" but it's behaving like a toggle switch I can't understand why it works with the menu and not the short cut key when it is doing the exact same thing. anyway, as soon as I figure it out, I will update the download link.

Finally, a request. This may not be appropriate for your project, or your intent with this editor, but I would like to see an expansion on the buffer, "model", concept. In other words, if I want to create a "model" for a complete tree, it would be nice to be able to build that tree, including collision area, and layer area (so a character can walk behind, or in front of the tree.)



I debated weather to do that or just a single layer. I opted for the single layer sense you can actually paste the model in any layer you want.
if it is pasted in the collision layer(which I haven't tried, and hoping it works),any none empty tile gets converted to a collision tile.


Also, I would like to be able to open a "work" window, where I build the prebuild "models", instead of having to do that in the main editing window. But maybe this is beyond the scope of your current project.



I want to integrate editing into the buffer and a menu "buffer create" option which should more or less solve that and should not be too hard to implement.

I have debated on allowing multiple buffer windows but I haven't figured out a way to manage them. i mean displaying them. I don't want to croud the desktop with say 20 objects that won't be need at a single time. Maybe I can have a separate screen like I do to view the map where the user can choose the model then switch to pasting that specific model. what do you think?


Also, what are your plans for "viewing the map???" I believe you should add an option to view the map in a selected resolution (full-screen), and have a "fake" character be able to navigate the level, for faux-pa testing.


I think I might be going over my head because I don't know how I am going to do this but I want to add an object layer(values and descriptions). a layer where you can assign values to an object such as attach two or more tiles so they can move in a uniform way or be animated. I don't want to go beyond that sense I think that would take away the editors flexibility and purpose as it is supposed to be a general purpose tile map editor.

the collision layer is an option sense some tile map designers create two layers a graphical tile layer and a collision layer the collision layer is for collision only that is where the objects move or collide with in a game. the player doesn't get to see the collision layer but it's synchronized with the tile layer. the collision layer is the only layer where collision takes place in a map weather it's for walking, falling or stopping. that in itself makes it optional sense some programmers would rather program to check by graphical tile number than by collision layer value.

I am basing this information on what I have experienced from seeing a limited number of tile map editors. There are a lot better ones I know, but I wanted to make one for my own experience.

Bare in mind that this is the first time I try to make a tile map editor or a project of this magnitude. Honestly, I don't know where this will take me as far as finishing it but so far I feel very optimistic.

thanks to everyone who has tested it also.


Nate the Great(Posted 2010) [#21]
cool stuff! I plan to make one of these for myself so I never have to write another hacky editor for an in progress tile based game. keep it up man!

I also like how you use your very own gui, that must have been tough to write.


Jesse(Posted 2010) [#22]
@Nate thanks for trying it out and for your comments.

I also like how you use your very own gui, that must have been tough to write.


yes, it has been a bit of trouble specially with no reference code or help to base it on. As it is, it's barely usable. the main GUI need a bit of work as well as the rest of the gadgets. I stop putting my full attention on it sense it is really time consuming. now, I'll do modifications when I find I need them.

I have fixed the bugs mentioned previously and modified the program to the ability to keep on pasting the buffer until the right mouse button is selected.

I have updated the link in the first post to reflect the current state.


Jesse(Posted 2010) [#23]
I was trying to convert my editor to Mac and Lenux. I haven't tried it on Lenux and currently I am trying to port it to Mac. I guess it's going to be a lot more work than I imagined. I don't know how many persons here have ppc macs and I was wondering if I should even make an attempt at porting the code to PPC. The other problem is that my desktop video card has recently fried and I am stuck with my laptop and the only place I have lenux installed is in my desktop ( split lenux and windows xp) so I guess that is a no go for now.

I don't have too much experience with macs and all I ever owned is my g4 Ibook and hardly use it sense I feel more comfortable in windows. My ignorant question is; do all Mac, Intel and PPC, have a one button mouse?
I am used to programming the right mouse button to do gestures. I am guessing that wont work in macs but that is just my ignorant input.

any ideas?

I have updated the download link in the first post to current state.


Nate the Great(Posted 2010) [#24]
I assumed you could just compile the exact same code on mac and it would work all of the time. Is this not the case? maybe its something to do with xcode?


Jesse(Posted 2010) [#25]

I assumed you could just compile the exact same code on mac and it would work all of the time.



I just found out it doesn't. for starters it it goes into the file requester right from the start it's as if it is registering 'LCONTROL O' as soon as the program starts but with out touching a key. I can not input in to any fields of my requester GUI in the text fields and doesn't respond to the buttons.
The other problem is with the left and right mouse button. I use them for pasting and removing tiles and groups of tiles but sense there is no right mouse button that part is not working. I don't know if the lcontrol is the same in windows as in mac but it seems to not be responding to the conbination of the lcontrol key and the left mouse button.

that was just a straight port of the running windows executable posted above.


Jaydubeww(Posted 2010) [#26]
As far as I know, most Macs have a one button mouse. Except the Magic Mouse has a "right" click; having two fingers on the mouse, lifting your pointer finger up, then lifting your middle finger up then clicking with the middle finger. Other than that, holding control and clicking the mouse on a mac is the "right click" for those without a Magic Mouse.


Jesse(Posted 2010) [#27]
I have to figure out a work around for all the non working stuff as I use the Lcontrol + key for hot keys and the right mouse button to delete tiles.
what I don't understand its why the program starts with the the requester active if in windows it starts normally.

I guess, I'll have to do some serious debugging and logic modifications if I want it to work in Mac computers. I thought it was going to be so simple.

I haven't even tried Lenux. :(


Nate the Great(Posted 2010) [#28]
have you tried flush keys at the beginning?


Jesse(Posted 2010) [#29]
no, but I'll find out tomorrow. Thanks.


Jesse(Posted 2010) [#30]
well I found out that, that wasn't it.
what I found out is that doing a direct copy of all the windows files including .o and .a files is some what problematic. I didn't realize that the compiler was using the windows .bmx folder files from my windows build to create the mac executalbe. As soon as I unchecked the Quick Build it started working as spected.
Sad it took me this long to figure it out.
Any way, I have adopted it to work with macs if any one wants to test it:
for macs undocumented commands:
Left shift +mouse button+ mouseMovement selects an area of the map.
Left ctrl + mouse button select tile from map
left system + mouse button unselects buffer tiles/remove tiles.


Jesse(Posted 2010) [#31]
I am currently in the process of implementing an "init file" (initialization files) file parser I just seen a couple of samples, one from the code archives by Madk and one from Here: http://www.socoder.net/?showcase=23426. and I decided to do one my self, based on this two. not exactly the same for either one but I did used some ideas from each. this is what I got so far:

it can be tested with this init file:


init file format:

;comments
[section name]
variable = value ; do not name 2 or or more variable name with the same name per section, as it will only be able to access the first one with the search.
.
.
[section name]; do not name 2 or more the same as it will be able to access the first one through the search only.
.
.
[section name]
.
.
.


it processes strings,floats, integers, bin int strings, hex int strings and booleans((true/false))

it does not work with values longer then integers or floats) I have yet to add the ability to write files but is in progress. if any one is interested in using it feel free to use it with out any limitations.

I have limited it to those variable types sense that is all I need at this stage but will modify as needed.

once I finish the ability to create ini files, I will add it to the editor.
the print function was only added for the purpose of testing. and will not be included in the actual parser.
I will not post any more update to the parser unless people show interest in it .


Jesse(Posted 2010) [#32]
I finally implemented the parser for the ini tile and is working fluidly(I think) from what I have tested.

how it works:
the editor creates a default ini file if the ini file is not included or is deleted. the "ini" file can be modified and set to work for a specific computer. The graphics mode can be set to "window = true" for window mode or "window = false" for full screen mode, As long as the graphics card support it. I suggest to only attempt to set a mode that is known to work, as invalid modes will more than likely will: crash the editor, will cause a garbled screen or will shut down the monitor.

If the editor is closed while working with a map, as long as the map has been saved or loaded, when the editor is restarted the map will continue with the previous editor map file and the previous editor settings.

The windows can be resized only through the ini file. I will implement an "ini" settings window; is in my to do list.

implemented the ability to save buffered objects.

if anybody cares to test it, update is in the first post.