Tilemap Editor
23yrold3yrold

Tilemap Editor (105KB source, binary, and makefile)

Just to show you I do actual work between posts ....

This is an Win32/Allegro tilemap editor I'm making for my game. I plan on adding quite a bit more (main.cpp has a to-do list) but I'm throwing it out now just for kicks. Firstly, while it's not as general purpose as it will be in the future, it's pretty simple, so maybe someone can hack around in the source and make one for their own purposes faster than starting from scratch. I've already brought this post to SSC's attention ;) The code is pretty decently laid out, though it definitely needs cleaning up. I got my hands dirty in it all weekend ...

Secondly, I'm open to further suggestions as to what to do with it. Functionality-wise.

Thirdly, it still doesn't draw the border and scroll bars (entirely) in the main window. This is a problem I posted about in the Programming Forum a while ago, but never managed to fix. First person to nail it gets ... um, renown, I suppose ...

There's not a whole lot to it. The left mouse button draws, the right has several secondary functions available from a drop-down on the left. You can zoom in on both the map window and the tile window using + and -. It has some cute tricks, like easy importing and exporting of tilesets. Cut, copy, paste, and delete are all in there. Plus a floodfill. Many keyboard shortcuts are to come; clicking around in the menu gets tedious. One cute feature is if you select an area which is longer than it is wide (or vice versa), then try to Insert Rows/Columns. See? It can read your mind if you let it ;D

The main to-do's include an undo (naturally), layers, plus stamps (self-explanitory) and something I call clone-stamps. Say you have one of a hill going up, leveling out, and going down again. Like the clone tool found in most image editors, you can clone bits of it where you need them, instead of drawing a repetetive pattern over and over, but without making a zillion stamps for all occasions. Not sure if any other editors do that, but I'm interested in seeing how useful it might be.

Plus it needs to make more versatile tilemaps. Right now it uses bitmasks for collision detection, but there should be an option to just make walkable/non-walkable tiles, among other things. Bitmasks would be overkill for a Final Fantasy clone ;) Plus things like variable sized tiles, and color depth, and a decent default project, all of which I'll implement when I get around to File->New. No sweat.

Comment away.

kazzmir

why was it written for win32? pure allegro not good enough for you?

23yrold3yrold

No, actually :)

Bob

Segfaults on me, apparently performing an array overrun inside a Win32 call, called from within Allegro, called by a function in your program.

Can you supply a debug version, linked with the debug version of Allegro?

MiquelFire

When hitting the X to close (File->Exit don't work) it complains about an area not writible

23yrold3yrold

Crashes!? :o

Quote:

Can you supply a debug version, linked with the debug version of Allegro?

I would have no clue how. You have the source, no?
Modify my makefile to do it and I'll compile it, no sweat ...

Quote:

File->Exit don't work

Yeah, I hadn't bothered yet since the X works fine. For me, anyway. This is weird; I can understand if I missed some stuff, but it should at least run fine for the most part. No crashes or anything for me ...

The bald alien down there said:

yep crashes here too...

AAARRGGHHHH!!!!
>_<

Would your OS's (W2K, XP, Win98) matter? Feel free to mention them if there's this many problems ...

Steve Terry

yep crashes here too... it just shows the drmingw32 exception window but with no output... just a blank window...

Ultio

Definitely crashes upon startup. Can't really give you more than that. I'm on an XP box. Also, try to include the dll in that acrhive, or at least at a separate location. It's a pain when I don't have a specific allegro.dll when I'm going to test someone's program :) Much more convenient for the user if they don't have to go searching for the dll. ;)

X-G

Yay for segfaults!
Yes, I got one too. And the Dr. MinGW window is indeed empty upon debugging.
WinXP Home, gcc 2.95.3-5, Allegro 4.0.0.

Dark

Can't even connect to get it.. :-/

EDIT

Runs perfectly. :)

Win98Se
AMD Duron 1.1ghz
128mb pc100
Geforce2MX 400

23yrold3yrold
Quote:

Runs perfectly.

THANK YOU!!!

I was beginning to think I forgot a vital file. Even though there aren't any ::)

Wh47 sI Wr0n6 Wi7H j00r C0mpU74r5!!!``11~! >:( ;)

What about compiling your own versions? That work?

SonShadowCat

Works perfectly for me as well.

Win2k
AMD athlon 1.1ghz
324mb SDRAM
TNT2

Ultio

I haven't tried compiling it myself, as I never usually compile stuff on my own.

It seems like people who aren't on XP are having no problems running the code. Maybe it's a XP thing with NTFS file format? Are you doing any specific directory finding stuff?

23yrold3yrold
Quote:

Are you doing any specific directory finding stuff?

The only file it comes with is the tileset, and that's the only one it loads. You can also save/load maps/tilesets, but from the sound of it you guys aren't getting that far ;)

Bob requested a debug version for some reason; anyone wanna tell me how to do that? Never bothered with how to do that ...

Thomas Fjellstrom
23 said:

Never bothered with how to do that ...

Really? w0w. Just how do you debug then?

compile the program with the alld (allegro debug) lib, and add -ggdb3 or -gstabs to the compile line of your makefile (where is makes the object files). also make sure not to include -s :)

23yrold3yrold

Okay. Now what's so special about a debug version?

Quote:

Really? w0w. Just how do you debug then?

I find de bug, I fix de bug ....

EDIT:

   g++ -o Main.o -c Main.cpp -gstabs
   g++ -o TilemapEditor.exe CTilemap.o Main.o rsrc.o -Wall -O2 -s  -ffast-math -fom
it-frame-pointer -funroll-loops -mwindows -lalld
   C:\DEV-CPP\BIN\..\lib\gcc-lib\mingw32\2.95.3-6\..\..\..\..\mingw32\bin\ld.exe: cannot find -lalld
   C:\DEV-CPP\BIN\MAKE.EXE: *** [TilemapEditor.exe] Error 1

Thomas Fjellstrom

You need to compile the debug lib :) as in DEBUGMODE=1 on the make command when making allegro.

also in regards to 'i find de bug, I fix de bug....' Its alot easier to find out exactly whats going wrong with a real debugger. like Dr.Mingw or gdb. (though I could never get gdb to work on windows...) Seriousloy, with gdb on linux, it pin points me to the exact line the SIGSEGV (segfault) occured on. Mind you it gets harder when debugging a threaded application but still easier than trying to find out what happened by staring at the code til I find the error...

Ultio

Well, when the program crashed, I had the option to debug it, as I have MSVC. However, it turned up for the worse. MSVC totally funked out and stopped responding. This is either one HUGE bug, or something was just clunky with my computer at the time :)

Good luck debugging.

Matthew Leverton

It crashes here on XP for me:

UpdateWindow(mainwindow);

from within WinMain (right after the classes are registered).

I created my own binary using MinGW32. It worked sometimes, sometimes it didn't.

Flecko

WinXP w/ service pack here and *boom*...crash.

Haven't had time to skim the source yet, but I'll try if I get some free time tomorrow.

-Flecko

MiquelFire

??? Am I the only XP user who can run this???

23yrold3yrold

Apparently :P ...

Quote:

as in DEBUGMODE=1 on the make command when making allegro.

So:

   fix mingw32
   make DEBUGMODE=1
   make install

Like that? Isn't there a third library; profiling or some such?

Quote:

It crashes here on XP for me:
UpdateWindow(mainwindow);
from within WinMain (right after the classes are registered).

Well that's just queer ??? Nothing fancy or error-prone going on there, or in WM_CREATE of WndProc or anything else relevent ...

MiquelFire

Unless I'm building a static version of Allegro, I just use

make installall

installs all three versions (one of which I don't understand, profiling)

Thomas Fjellstrom

It doesn't crash on my machine...

[edit]
Though I did find a problem, the tiles don't fully load, and I can only use the 'place tile' tool. None else work.[/edit]

p.s. Don't mention me being in windows, I neded to get something with shareaza ;) Its the only client that supports the Gnutella 2 network...

23yrold3yrold

How do they not "fully" load? And if the left mouse button works, the right one should too ??? The default behavior is to erase tiles ....

I was hoping for more in line of the three reasons I had for "throwing it out" ::) I'm at a loss as to why this thing isn't working right for everyone. Did anyone have problems running Bola? I don't recall any ....

Thomas Fjellstrom

Ok the second mouse button works, But that was definitly not what I was expecting. I thought the drop down would change what the left button did...

And the editor only shows one tile.

miran
Thomas Fjellstrom said:

And the editor only shows one tile.

I thought that was strange too. I thought maybe a listbox containing all the tiles would be nice but the modeless "View\Tile Window" is OK too, just a little hard to find. Maybe you could put a button somewhere or something...

23yrold3yrold
Quote:

Maybe you could put a button somewhere or something ...

To bring up the window? Is not Ctrl + T enough?

Sounds like it wasn't as intuitive as I'd hoped :-/ ....

Thomas Fjellstrom

If you have a gui, it should be intuitive enough that users who haven't read the key-bindings docs can use it. IE: have menu items, or buttons.

I mean, using a map editor shouldn't be like VI/VIM/Emacs.

23yrold3yrold
Quote:

IE: have menu items, or buttons.

The tile window WAS a menu item :) Ctrl + T is just the shortcut. I suppose I could add a button, but I'm still figuring out what to put over on the left, and it seemed a little redundant at the time. I'm sure I'll write up some docs when it's more complete.

Thomas Fjellstrom

hmmm. Sory, :) didn't notice the menu item. Was probably distracted because there was only one tile to choose from.

23yrold3yrold

That's the current tile, not the only tile ;)
What if I made the tile window open if you double click the current tile window?

Thomas Fjellstrom

Then what is all that space for? The tiles should be listed down the side or something. Maybe in a listbox, or a scrolled window or something.

X-G
makefile said:

P\BIN\MAKE.EXE: *** [GameTest5

... right at the end. Wtf? ;)

Anyway, through mysterious ways, running it through GDB made it work. Outside of GDB it still crashes.

gnolam

X-G: Heisenbug? :)

X-G

Something of an inverse heisenbug, wouldn't you say? I.e. the bug goes AWAY when you observe it ... ;)

23yrold3yrold
A talking cookie said:

... right at the end. Wtf? ;)

Yeah, I just noticed that a while ago myself. Weird ... :P

I forgot to ask; does anyone have problems seeing the scrollbar buttons? The original bug I had. Try resizing the window slightly when it runs; some of the controls seem to lag behind :-/

Quote:

Then what is all that space for?

Whatever comes to mind; I'm not done yet ;) I like my tile window; you can even zoom out to see more of it at once 8-)

Thread #233605. Printed from Allegro.cc